With a script groovy, written in a BeanShell PreProcessor, I generate a random JSON object with some parameters. I am not able to include this object created (I've used JsonBuilder in the script) in the body of HTTP POST request in JMeter. This is a snippet of my script where I create my JSON object:
...
def json = new JsonBuilder();
def root = json parameter1: value1, parameter2: value2, parameter3: value3, parameter4: value4;
bsh.shared.root.process();
vars.put("BODY", root.toString());
I want to pass this object in the BODY DATA section of HTTP POST request in JMeter:
${BODY}
This is the response data that is generated:
The request content was malformed:
Unexpected character '$' at input index 0 (line 1, position 1), expected JSON Value:
${BODY}
^