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

Further reading

Problem with a question

API Testing · Junior · question 27

Test yourself

Take the API Testing · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz