How to get next request name or id

I have 4 requests with names request1,request2, request3 and request4 in this order.

I want to create a workflow where after each request 4 is called, so the workflow would be

request1
request4
request2
request4
request3
request4

so whenever I run a request I store the request name to a variable.

pm.environment.set(“requestName”, pm.info.requestName); (Say i get request1)

Then call request4 using sendNextRequest(“request4”) ,

Now in request4, I want to do something like

sendNextRequest(pm.environment.get(“requestName”)+1) so that it will call the next request (say request2)

is there a way to do this

@praveendvd0pravu Yes, you can write the following to access the name of saved request:

let name = request.name;

@sivcan

Thanks for the reply i am looking for accessing the next request in the Q and not the current . Is there a way to get next request in the collection

You could use the Postman API to load the collection details, find the current request, then grab the one after it.

It would be something along the lines of what I proposed in this post:

1 Like

Thanks for this just wanted to know whether there where any inbuilt solution , thanks for this again

1 Like