Increasing the Iteration count in Test Section

I’m new to postman and am trying to create a collection with 5 requests.


The requirement is that the Request 1 runs for every iteration. After that I need to run only 1 of the other 4 requests based on the first column in the datasheet (CSV File) I’m using for running the collection. Once that request is executed, I need to begin the next iteration by running the Request 1 again. For this, I’ve given the below If block in the Test of Request 1.

var RequestToExecute = pm.iterationData.get(“Request”)
if (RequestToExecute === “Req2”) {
postman.setNextRequest(“Request 2”);
else if (RequestToExecute === “Req3”){
postman.setNextRequest(“Request 3”);
else if (RequestToExecute === “Req4”){
postman.setNextRequest(“Request 4”);
else if (RequestToExecute === “Req5”){
postman.setNextRequest(“Request 5”);
else if (RequestToExecute === “END”){

In the Test of Requests 2 to 5, I’ve used the setNextRequest statement to reference Request 1.

The issue I am running to is that the Iteration not getting incremented and same row is running again and again in an infinite loop. Can someone please help me in how to increate the Iteration count in the Test section.

You don’t want to call request 1 again, as that is what is causing the infinite loop. You are still technically in the same iteration at this point.

You actually want it to end the current iteration by using setNextRequest(null). The collection runner will then run the next line in your CSV.


Thanks a lot Mike. It fixed the issue.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.