I’m sure this is just a syntax issue somewhere on my end, or I’m not understanding the console output. I have this script that will read through an array of objects:
let mzs = pm.collectionVariables.get(“mzs”);
if(!mzs || mzs.length == 0) {
mzs =[{“id”: “test1”, “email”: “[email protected]”,“firstName”: “test”,“lastName”: “test1”,“passwordClearText”: null,“groups”: [“TestGroup”]},{“id”: “test2”,“email”: “[email protected]”, “firstName”: “test”, “lastName”: “test2”, “passwordClearText”: null, “groups”: [“TestGroup”]}];
}
let currentmz = mzs.shift();
console.log(currentmz)
However, with this I get a syntax error if I try to call just the currentmz variable as the body.
Where I am a little confused is the console.log for currentmz shows the proper json object:
But in the response body I am just seeing the raw input of the variable:
Is that expected, or should I be seeing the full value for the variable as the request body? For more context, if I take that json object and put that as the body, this call works fine:
So, again, pretty sure I’m just missing something really small here, and any help is appreciated. The end goal will be to dump this into a collection and iterate through multiple objects, but need to get 1 working before I get to the post script stuff.
Thank you!!