I have a couple of requests in a folder, and I am using a CSV data file to run the folder multiple times; however, only the second request needs to be run on the 2nd and subsequent iterations (i.e. the first request is only run in the first iteration). To achieve this I tried the following code in a pre-request script of the folder, such that:
iterationCount = pm.info.iteration;
console.log(iterationCount);
if (iterationCount > 0){
postman.setNextRequest("My_2nd_request");
}
I am aware that if the postman.setNextRequest function is placed in the pre-request script of a request, then this is still called AFTER the current request finishes (Building request workflows | Postman Learning Center). I had thought that as this was within the folder, then this will be action before ANY request is made. However, the first request is still called at the beginning of each iteration.
The pre-request script of the folder is simply something that will run before every request in the folder run, and the rules regarding the postman.setNextRequest function still apply - i.e. that it will run AFTER the current request finishes. This means that it looks like the first request MUST complete before the postman.setNextRequest function takes effect (so you cannot skip the first request at all).