Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chaining postman requests - call postman request from another request?

Tags:

rest

postman

I have two postman requests x,y which hit endpoints in two different rest api X,Y. x will give me an authentication token which is necessary to make the y request. How do I make the request x inside request y ? That is, call x from inside y.

PS - I have already figured out how to use request x to setup environment variables (auth token) which will be picked up by y.

like image 661
Postman Avatar asked Nov 16 '25 14:11

Postman


2 Answers

If you want to do it in one shot, you can use the pre-script option.

Pre-script are triggered before the request. So if you make a request and set the token in an environnement variable, the next call can use the token. You should check that page. It seems outdated, you should replace pm by postman.

You might also want to add a pre script request to your collection. This way, every request of that collection will be precede by a request to the authentification route for exemple.

like image 123
Ernest Jones Avatar answered Nov 19 '25 10:11

Ernest Jones


Have a look at this: https://blog.postman.com/conditional-workflows-in-postman/, if you want to call a specific request from within a request, the postman.setNextRequest() function will do the job.

Alexandre

like image 41
A.Joly Avatar answered Nov 19 '25 08:11

A.Joly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!