0

I send POST request with the following JSON in body data

enter image description here

The problem is that the unixTimeValue variable is not setting

This is how my JSR223 PreProcessor looks like enter image description here \

2 Answers 2

1

vars hold String values, you can convert your double when putting value:

vars.put("unixTimeValue", String.valueOf(a));
Sign up to request clarification or add additional context in comments.

Comments

1
  1. You can change your lines 1-14 to:

    vars.put("RANDOM_STRING", org.apache.commons.lang.RandomStringUtils.randomAscii(12))
    

    See RandomStringUtils class JavaDoc for more potentially useful functions

  2. Change your line 20 to:

    vars.putObject("unixTimeValue", sin);
    

    as vars.put() function accepts only Strings while vars.putObject() accepts pretty much everything, see JMeterVariables class JavaDoc for more details

  3. Since JMeter 3.1 you should be using Groovy language for scripting mainly because Groovy has much better performance comparing to Beanshell, see Apache Groovy - Why and How You Should Use It article for comprehensive explanation with examples

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.