I'm playing around with Postman REST extension's collections feature.
I have 2 requests: the 1st returns a sessionId in its response body and the 2nd requires the {{sessionId}}
value as query param. Can I tell Postman to save the body of the 1st response to the {{sessionId}}
variable?
I currently have to a) execute 1st request and b) copy response body and paste it as a value of the 2nd request's query param every time...
thanks, -nikita
There are 2 ways of saving the response to a file: Click on the small down arrow besides the "Send" button, this will show the "Send and Download" button. Click on it and postman will ask you where to save the response, when the request is done.
Absolutely Yes! Here is a json example: I added the following to the Tests Tab of the first request:
var data = JSON.parse(responseBody);
postman.setGlobalVariable("session_id", data['session_id']);
Basically retrieving the data from responseBody and set it as a global variable
Then in the second request, the URL would be something like this:
http://{{whateverhost}}/api/v1/somefunction/{{session_id}}
Hope this helps. Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With