This is my ‘Test’ script
var resp = pm.response.json();
var token = resp.access_token;
pm.globals.set("service_token", token);
Using the desktop app, version 6.6.1
I’m making a Type “No Auth” POST call for an access token. The call returns 200 status with a valid JSON object,
{
"access_token": "jwt_token_value_redacted_for_this_example",
"scope": "read:client_grants create:client_grants delete:client_grants update:client_grants read:users update:users delete:users create:users read:users_app_metadata update:users_app_metadata delete:users_app_metadata",
"expires_in": 3600,
"token_type": "Bearer"
}
In ‘Test Results’ I get “There are no tests for this request”
In Postman console when I run resp = pm.response.json();
I get “Cannot read property ‘json’ of undefined”.
pm.responseBody
and pm.response
return ‘undefined’
I don’t seem to be able to get at the response body at all. Any idea why, please?
Ultimately, I wish to store the access token from the response in a global variable that I can then {{use}} in various API calls.
Thanks