I’ve been following this thread (and a few others):
Extracting Data from Responses and Chaining Requests | Postman Blog.
and was able to successfully extra my token from the results into a variable.
I am able to able to view the variable in the Quick Look Window as shown in step 2.
I am unable to successfully use that variable in my Gets as shown in step 3.
The response of my Authentication post is:
{
“access_token”: “LongStringOfTextHere”,
“expires_in”: 3600,
“token_type”: “Bearer”,
“scope”: “api.read api.write”
}
and this is the body:
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable(“ReThinkProductionToken”, jsonData.access_token);
If I hover over the Quick Look window I get the variable varReThinkProductionToken and it is populated with the value of the returned Access Token (as expected).
When I call my “Get” as such:
https://api.rethinkbehavioralhealth.com/api/v1/Appointments/12345
It works if I manually copy and paste the Bearer token into the authorization section. But it isn’t chained, and must be updated each time the auth expires.
Following the step 3 directions on the link above, I wen to the Body section, then chose form-data.
I then created a key named “token” (I have also tried “access_token” and “Token”) and when I type into the Value box, I am prompted for my variable ( {{varReThinkProductionToken}} ) and choose it.
When I press send I get a 401 unathorized error, unless I go to the Authorization tab and paste the real token value into the Token field. The drop down for type is Bearer Token, if that matters.
What am I missing?