Hi all,
Iβm running a collection with the JSON datasource file, which apart from other things has this: element:
"wheelsize" : "21\" WHEELS"
When it is being loaded into iteration data, it starts to look like this:
console.log(pm.iterationData.get("wheelsize"));
=>
21" WHEELS
Now when I use this variable in the request body like this, as I do with all other strings
"wheelsize": "{{wheelsize}}"
it is obviously no good as the resulting body looks like this
"wheelsize": "21" WHEELS"
and this is not a valid JSON for the request.
As a solution I do the following - in the pre-request script:
pm.variables.set("wheelsize", JSON.stringify(pm.iterationData.get("wheelsize")));
which turns the string back into initial
"21\" WHEELS"
and then in the body I donβt use quotes
"wheelsize": {{wheelsize}}
But that is requires such special processing of each string field with quotes inside.
Is there a better way?