sromit
sromit

Reputation: 1112

postman not returning the actual value in console

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

enter image description here

Upvotes: 0

Views: 402

Answers (1)

Ranjith Bokkala
Ranjith Bokkala

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);

enter image description here

Upvotes: 1

Related Questions