I am trying to set the response in a variable but the response is just an ID, not an object. I used
var resposseBody=pm.response.json();
or
var resposseBody=pm.response.text();
but they didn't work. How can I set the response below in a variable?
"3707ff3d-2af9-4ea1-a6aa-08d9a8ee3cb3"
CodePudding user response:
To save that value to a variable, add this to the Tests
script:
pm.globals.set('id', pm.response.text());
This is an example using the global scope but the variable can be set at the Environment or Collection level.
There aren't many details in your question so it's difficult to offer any more of a solution than this one.
CodePudding user response:
If the response is in json format, like
{"id":"3707ff3d-2af9-4ea1-a6aa-08d9a8ee3cb3"}
then you can get simply with
responseJsonData=pm.response.json();
responseId=responseJsonData.id;