Tuesday, February 25, 2020

POSTMAN - How to save a response field as a variable

In the "Tests" tab, use the code below:

var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("myId", jsonData.id);

It will save the id field in the JSON response payload to the variable myId. The variable can be used in another request this way: {{myId}}

No comments:

Post a Comment