hello everyone,
I wanted to know if there is an option in the collection runner to do a POST request, and then save the token that I get and move it to the next GET request in the header.
@dassamaor Welcome to the Community
Yes definitely you can do that. Please spend a min reading the below blog:
In just words, you just need to extract the token and store in a variable to use in the future requests.
For example, if my post request returns the “access-token” in response I would write the below code:
var resp = pm.response.json();
if (resp.access_token) {
postman.setEnvironmentVariable("accessToken", resp.access_token);
}
And in the next GET request, it goes on to the header like this:
Hope this helps…
To dive-in deep to acquire more knowledge if you are using OAUTH2, I suggest you to read the below article:
Have a good day
Yes! Thank you very much…! I really appreciate it!
another question: when I am doing the runner I should put all the requests in the same folder?
there is an option to do the flow with other folders?
Hello @dassamaor, you can organize your folders/request in the way you wanted to be. Both in collection runner and newman you have the option to select the folders you need to run, or you can run the entire collection.
So basic thing here would be the collection, and all the requests inside that are completely based on your requirements. You are free to organize the way you need to look like.
If you are using newman runner, you can select the individual folders, to get more details on that please refer the similar question, answered already: