I want to have postman tests running on my CI environment. Now, before I make a call to an endpoint, I need to make a call to one of our oauth endpoints, to ensure I have access token. On postman there is 2 year old ticket with a ton of upvotes and suggestions to use setNextRequest in pre-request (which is supported from postman 4.5, apparently). Thus, I had the following in my pre-request section:
var responseBody = postman.setNextRequest("/oauth/token");
It did not work, it seems the "/oauth/token" never even been called (didn't show up in the postman console). I am sure I'm not the first person bangin my head against this scenario, so my question - is there a way to call an item from the collection (the one that gives me access token) ? That is, I do not want to have the same oauth request duplicated before every test requiring said access token.
I could see you are using responseBody
in pre-request section. Although you are just trying to set it to next request. responseBody
is not available in there. responseBody
is available in Tests
section only (obviously due to the request already been executed).
Regarding your scenario, why don't you follow:
This will make sure all your request have access token generated on run time.