# Update token in header after post request in collection runner

**URL:** <https://community.postman.com/t/update-token-in-header-after-post-request-in-collection-runner/18453>\
**Category:** Help Hub\
**Created:** [December 14, 2020, 12:11pm UTC](https://community.postman.com/t/update-token-in-header-after-post-request-in-collection-runner/18453 "2020-12-14T12:11:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dassamaor](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dassamaor](https://community.postman.com/u/dassamaor)\
**Post date:** [December 14, 2020, 12:11pm UTC](https://community.postman.com/t/update-token-in-header-after-post-request-in-collection-runner/18453/1 "2020-12-14T12:11:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [December 15, 2020, 1:43am UTC](https://community.postman.com/t/update-token-in-header-after-post-request-in-collection-runner/18453/2 "2020-12-15T01:43:01Z")

</div>

@dassamaor Welcome to the Community 👋

Yes definitely you can do that. Please spend a min reading the below blog:

> **[Extracting Data from Responses and Chaining Requests | Postman Blog](https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/)**
>
> Update: If you want to dig deeper into chaining requests, check out our related post called How to Make Money Using Postman:...

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:

```auto
var resp = pm.response.json();

if (resp.access_token) {
  postman.setEnvironmentVariable("accessToken", resp.access_token);
}

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/f/b/fb3e2d65e828d6d303af4b95d1df092ae9c4d4dc.png)

And in the next GET request, it goes on to the header like this:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/7/e70245a261299f1b964c3ecfd3410f4307a626ae.png)

Hope this helps…

To dive-in deep to acquire more knowledge if you are using OAUTH2, I suggest you to read the below article:

> **[How to Automate OAuth2 Token Renewal in Postman](https://allenheltondev.medium.com/how-to-automate-oauth2-token-renewal-in-postman-864420d381a0)**
>
> Discover how to automatically renew your OAuth2 access token in Postman so you never have to click the “Get New Access Token” button again.

Have a good day 😊

---

<div class="post-metadata">

**Author:** ![dassamaor](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dassamaor](https://community.postman.com/u/dassamaor)\
**Post date:** [December 16, 2020, 2:12pm UTC](https://community.postman.com/t/update-token-in-header-after-post-request-in-collection-runner/18453/3 "2020-12-16T14:12:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [December 17, 2020, 1:25am UTC](https://community.postman.com/t/update-token-in-header-after-post-request-in-collection-runner/18453/4 "2020-12-17T01:25:24Z")

</div>

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:

> [@How to run a sub-folder in Postman](https://community.postman.com/t/how-to-run-a-sub-folder-in-postman/11103):
>
> I have a collection and many of sub-folder in this collection, how can I run specific folder? I tried with --folder parameter but it does not work
