How to set Dynamic variable Token in Postman API

Postman is most populer API tester for Web Developer, Mobile Developer, Etc. You can colaborate with Teams and sharing API with others.

You can set Variable based from response request like accessToken, statusCode, and many variable that you want.

Step 1:

Open Postman and Login

Step 2:

Create Environment (Click eye icon of environment)

Click Add

Example use “accessToken” variable

In this case, I have Login API for example

I will store “accessToken” from JSON Response to “accessToken” variable

Click Tests Menu

Ensure you have select Enviroment and type script inside tests menu like bellow:

Click send button and check variable accessToken that will be change with new accessToken from JSON response.

You can use accessToken for each request with authorization

You can use that in header Authorization