0

I am trying to automate API testing using Postman. Apart from AuthAPI every other API is decorated with [Authorize] so I need to pass token.

In my collection, the first API is AuthAPI, This API returns the JWT token. if I run the API in collection runner, I am getting 403 error for all the APIs in the collection.

However, If I do manually copy the token recieved in the AuthAPI resonse & paste in the Authorization header, it returns the desired response.

How do I attach the token received in the response of the AuthAPI in the header of the subsequent request (Postman) when running the API in the Automated way.(via Collection Runner)

Thanks

Kgn-web
  • 7,047
  • 24
  • 95
  • 161

2 Answers2

0

You can use the environment variable to store the token an use them in the subsequent request. Also, the first request should be Auth API.

Check the postman console for the request details, You might have encountered the issue similar to this thread. Check whether the header has bearer or Authorization in the request details.

Santhosh Tpixler
  • 361
  • 4
  • 12
0

use variables inside Postman and Collection Runner

http://blog.getpostman.com/2014/02/20/using-variables-inside-postman-and-collection-runner/

Add your variable here

then use variable in clollection