Postman has building workflow feature where you can specify which request you want to call next.
After you reach the Req4, call the Req2, which is after Req1 based on a counter.
This can be achieved in the Tests
tab of the postman request window.
Pseudo code -
set 2 global/environment variables , iteration = <some number you need>, iteration_ref = 0
<In Req1 window>
if(pm.globals.get("iteration_ref") < pm.globals.get("iteration")-1)
postman.setNextRequest('Req2')
<In Req2 window>
if(pm.globals.get("iteration_ref") < pm.globals.get("iteration")-1)
postman.setNextRequest('Req3')
<In Req3 window>
if(pm.globals.get("iteration_ref") < pm.globals.get("iteration")-1)
postman.setNextRequest('Req4')
<In Req4 window>
if(pm.globals.get("iteration_ref") < pm.globals.get("iteration")-1)
{
postman.setGlobalVariable("iteration_ref",
Number(postman.getGlobalVariable("iteration_ref"))+1);
postman.setNextRequest('Req2')
}
Or only in the last request, if you are pretty confident about the order of the requests set in the collection.
<In Req4 window>
if(pm.globals.get("iteration_ref") < pm.globals.get("iteration")-1)
{
postman.setGlobalVariable("iteration_ref",
Number(postman.getGlobalVariable("iteration_ref"))+1);
postman.setNextRequest('Req2')
}
Make sure, you have the Req1(Post Request) at first in the collection and only 1 iteration
in the collection runner. We are using a global/env variable for iterations.
PS: I highly recommend having a simple python or js script using request library to call the APIs, the above flow is a witty hack.
Reference - https://learning.getpostman.com/docs/postman/collection_runs/building_workflows/