API Testing · Junior · Question 27 of 75
How do you reuse an ID from one response in the next request in Postman?
const body = pm.response.json();
pm.collectionVariables.set("orderId", body.id);- 1Copy it from the response by hand into every request
- 2Postman can't pass values between different requests
- 3Save it to a variable in a script and use
{{orderId}}
Show the answer
Correct answer: Save it to a variable in a script and use {{orderId}}
Explanation
Chaining requests this way lets a collection create, read, update and delete the same resource in order.