Ah, I guess I had misunderstood your question overall and didn’t go through the screenshots well enough previously.
Well, let me tell you that you cannot use {{
syntax in the test scripts, this is because the test scripts are run in a JS environment, and your variables won’t be resolved. If you marked it with "
then the JS interpreter won’t be throwing the error, and while the request is executed, your variables will be resolved as string, but in the case of the array’s this is why they’re getting converted to having quotes around them.
You’ll have to directly assign it like so:
// This is fine since it's for a string and it'll work
pm.variables.set("firmFcaRef", "000000");
// But for the array, you'd have to do this instead of setting the array to the local variable:
obj.payload.applicants = obj1;
// Now stringify the entire requestBody.
pm.environment.set("requestBody", JSON.stringify(obj));
I hope this helps.
I am guessing you were extracting out the applicants due to some specific reasons, but I am sure you can loop over the data and still build the requestBody data.