postmanpostman-collection-runner

How do i set up a bearer token in postman from an environment variable?


I have set up a collection in PostMan and am able to save my bearer token value to an environment variable successfully using the following test

var jsonData = JSON.parse(responseBody);
pm.environment.set("mytoken", jsonData.token);

but how do I set up a new call to use it?

I have tried adding a Header with

Authorization Bearer <mytoken>

but when I Post the Status is 401 Unauthorized


Solution

  • In the headers I needed to use

    for the key

    Authorization 
    

    for the value

    Bearer {{mytoken}}