Reputation: 1112
I am trying to set up a global environment variable, but postman is not setting the value. The script I wrote is
var jsonObject = xml2Json(responseBody);
console.log(jsonObject);
console.log(jsonObject.CreatePOReq.$.ProjectNumber);
pm.globals.set(("ofs_projectNumber", jsonObject.CreatePOReq.$.ProjectNumber));
console.log(pm.globals.get("ofs_projectNumber"));
But What I am getting in the console is very different - the last 2 lines should be identical, but it is not. What am I doing wrong
Upvotes: 0
Views: 402
Reputation: 379
Here two curly braces are there. and please below check attachment
pm.globals.set(("ofs_projectNumber", jsonObject.CreatePOReq.$.ProjectNumber));
instead of use below.
pm.globals.set("ofs_projectNumber", jsonObject.CreatePOReq.$.ProjectNumber);
Upvotes: 1