Fire a postman request from "Tests" of another request

I would like to run a postman request that is defined in my collection from the “tests” section of another request in the same collection.

Customize request order in a collection run | Postman Learning Center

However, this will not just run that request and return to your current request which is what I think you are asking for. It will just set that as the next request to run after the current request and all scripts have completed. It will pass the execution to that request and the flow will continue from there.

These is no way to do that as far as I’m aware, run a request and then continue execution from where you current are. There is some work ongoing for reusability of requests\scripts but I don’t know any timescales or how that is going to work in reality.

If you want to execute a request from the tests tab, then you could potentially use sendRequest but it will have to duplicate the functionality of the request you want to run.

Sending requests from scripts | Postman Learning Center

setNextRequest is useful only when you are running a collection, not when you are running an individual request right? (clicking on the “Send” button)

  • I am not running any collection
  • I don’t need any response back from the request that I want to run in the tests.
  • It is enough if I fire the request I want and forget it.

Thanks for clarifying, but the answer I’m afraid is that you can’t.

If you want to call another request, you have to use setNextRequest() or sendRequest().

setNextRequest() as you have noticed only works with the collection runner and only really sets the next request to run after the existing request and any code in the pre-request scripts and tests tab has completed.

sendRequest can be used as a script and doesn’t require the runner, but won’t just run a request that you have within the collection. You will have to mimic that request using sendRequest() so doesn’t quite give the re-usability that I think you were looking for.

The re-usability functionality you are asking for doesn’t exist in Postman at this point in time, so the two options above are functionality that does exist that you might be able to leverage.

Got it. Thank you Mike

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