I am trying to understand how to parse json with Postman.
My goal is to retrieve the value of WorkstationId and store it into collectionVariables.
Could some one point me in the right direction?
This is how far I got but it failed:
pm.collectionVariables.set("GETWorkstationIdStore", pm.response.json().value[0].Workstations.WorkstationId);
let GETWorkstationId = pm.variables.get("GETWorkstationIdStore");
console.log("WorkstationId from GET = " + GETWorkstationId)
You should be able to do just this in the Tests for that request:
let GETWorkstationId = pm.response.json().value[0].Workstations[0].WorkstationId
console.log("WorkstationId from GET = " + GETWorkstationId)
pm.collectionVariables.set("GETWorkstationIdStore", GETWorkstationId);
Both actually.
I am starting to learn.
So I can image that there is a tutorial of some sort that will explain to me how to build parameter for pm.responds.json.
for instance my line was
pm.response.json().value[0].Workstations.WorkstationId
btu it shoudl have been
pm.response.json().value[0].Workstations[0].WorkstationId
difference in the line is apparent
I would like to know why and when to apply those parameters.
Also looping through arrays sounds something I can use.
Would like to know more.