Reputation: 1002
I have 2 graphql http requests as following.
The first http request's response returning json like so:
{"data":{"customers":{"customerIds":["0e1c7b05-79c6-40c6-9144-7230a836fe04", "45677b05-79tt-56c6-9144-7230a836bbbb"]}}}
I then created the json extractor and the beanshell to save the customer ids in the property
The 2nd Http request then using the above customerids property as part of the graphql request body
but I;m getting the 500 InternalServerError due to the quotes in the list customerids below not being escaped. how can i escape them ?
POST data:
{"query":"query getCustomerInfo {\n getCustomerInfo(customerIds: \"["0e1c7b05-79c6-40c6-9144-7230a836fe04"]\") {\n firstName\n lastName\n school\n }\n}"}
Upvotes: 0
Views: 354
Reputation: 168072
Don't inline JMeter Functions or Variables into your scripts
When using this feature, ensure your script code does not use JMeter variables directly in script code as caching would only cache first replacement. Instead use script parameters.
So replace your Beanshell Assertion with the JSR223 PostProcessor and use the following code:
props.put("customerIds",vars.get("customerIds").replaceAll("\"","\\\\\""));
This way you will get the following customerIds
property value:
[\"0e1c7b05-79c6-40c6-9144-7230a836fe04\",\"45677b05-79tt-56c6-9144-7230a836bbbb\"]
Upvotes: 1