Reputation: 55
I send POST request with the following JSON in body data
The problem is that the unixTimeValue variable is not setting
This is how my JSR223 PreProcessor looks like
\
Upvotes: 0
Views: 1071
Reputation: 168072
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
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
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
Upvotes: 1
Reputation: 58772
vars
hold String values, you can convert your double when putting value:
vars.put("unixTimeValue", String.valueOf(a));
Upvotes: 1