postman.setNextRequest() ignore other requests in collections

Hi im using postman.setNextRequest() in my first request and calling the third request and with that its always ignore my 2nd request and end the collection.

I want to run my 2nd request as well afterpostman.setNextRequest() call.

Is there any way fro that ?

Assuming your requests are in this order in your collection 1 > 2 > 3 and you want to run your requests in the below order using postman.setNextRequest()
1 > 3 > 2?

postman.setNextRequest() is working as expecting in your example.

If you want to call request 2, then you’d need to use postman.setNextRequest("name-of-request-2") in request 3, so after request 3 has been completed it’ll run request 2.

Bear in mind, that after request 2 it’ll naturally go to the next request in your collection which would be 3.
So you’d want to use the below in request 2 to end the test run:


Hopefully that made sense?

Also, if you want to run your test collection in the order 1 > 3 > 2, why not just move the 3rd request so it’s the 2nd request in the collection so it’ll naturally run in the order you want without using postman.setNextRequest();

This is not working in the pre-req or anywhere for that matter:


I even created a “null” get request to see if the jump would work but it didn’t. The pre-req is supposed to stop the request from running but it isnt.

Any help is appreciated!

All code will be executed BEFORE the setNextRequest command is executed.

If I have 3 requests, named “1st Request”, “2nd Request” and “3rd Request” inside a collection.

If “1st Request” has the below code in its “Pre-request script tab”, it will hit the 1st Request, skip the 2nd and hit the 3rd Request.