Workflow: setNextRequest: how to control which request to be triggered under different folders

I have same named requests in multiple folders under 1 common parent folder.
some of those requests are called using setNextRequest

  • F
    • F1
      • r1
      • r2
      • r3
    • F2
      • r1
      • r2
      • r3

where r1 calls r3 in both the folders
postman.setNextRequest(“r3”); //in r1’s test

while running this collection on the folder F, found that while F1->r1 runs, it makes call to F2/r1 instead and same happens irrespective of F2 is a sibling to F1 or outside F. The pattern observed is " it picks the last request matching the name in entire suite"
Am I missing something or there is anything I can do about (without needing to have unique names of requests in multiple folders)

Is there any way out to control the ability?
Related discussion on github

1 Like

postman.setNextRequest() takes either the request name or ID.

There’s enhancements planned to retrieve the ID a little bit more easily, but in the meantime, you can determine the request ID either way:

  • View the collection documentation on the web, and you will see the request ID in the URL.
  • Use the Postman API to GET a single collection, and you will see the request ID in the response.
1 Like

Isn’t there any plans to support folder paths, in postman.setNextRequest() ? An other feature we really miss while writing runner flow, is the ability to access parent folder of the current running folder.

This was one of the major issues we had when using Postman/newman for automation.
If you use setNextRequest with a request name, and then at a later date your folder is duplicated, things will go wrong without any warning.
The logic should not jump around between folders, it should look in the current folder for a request of that name, and use it if found.
If not found, it should search parent folders - the exact method should be documented.
If the location to move to is ambiguous, an error message would be preferable to just choosing the first one.
All IMHO of course.

1 Like