Recall & Review
beginner
What does the
setNextRequest() function do in Postman?It controls which request runs next in a collection run, allowing you to skip or repeat requests based on conditions.
Click to reveal answer
beginner
How can you skip a request in Postman using
setNextRequest()?By calling
postman.setNextRequest(null), you stop the collection run from continuing to any further requests.Click to reveal answer
intermediate
True or False:
setNextRequest() can be used to create loops in a Postman collection run.True. You can set the next request to a previous one to repeat it, creating a loop.
Click to reveal answer
beginner
In which script tab do you write
setNextRequest() to control request flow?You write it in the Tests tab of a request, after the response is received.
Click to reveal answer
intermediate
Example: How to run
Request B only if Request A returns status 200?In
Request A's Tests tab, write:<br>if (pm.response.code === 200) {
postman.setNextRequest('Request B');
} else {
postman.setNextRequest(null);
}Click to reveal answer
What happens if you call
postman.setNextRequest(null) in a test script?✗ Incorrect
Calling
postman.setNextRequest(null) stops the collection run after the current request.Where do you place the
setNextRequest() function to control request flow?✗ Incorrect
You place
setNextRequest() in the Tests tab to decide the next request after receiving the response.Can
setNextRequest() create loops in a Postman collection?✗ Incorrect
You can create loops by setting the next request to a previous request using
setNextRequest().If you want to run
Request C only when a variable isReady is true, what should you do?✗ Incorrect
Use an if condition in the Tests tab to call
setNextRequest() only when the variable is true.What is the default behavior if you do NOT use
setNextRequest() in a collection run?✗ Incorrect
By default, Postman runs requests in the order they are listed in the collection.
Explain how
setNextRequest() can be used to control the flow of requests in a Postman collection.Think about how you decide which request runs next after one finishes.
You got /4 concepts.
Describe a scenario where you would use
postman.setNextRequest() to skip some requests.Imagine you only want to continue if a test passes.
You got /4 concepts.