When running a collection, you can branch and loop across API requests in Postman using the postman.setNextRequest("request_name");
function.
Set the request to be executed next
postman.setNextRequest("request_name");
Stop workflow execution
postman.setNextRequest(null);
Some salient points about postman.setNextRequest()
:
postman.setNextRequest()
is absent in a request, the collection runner defaults to linear execution and moves to the next requestFor more information about control flow, read about building workflows.