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