Reputation: 1
I created a post request in post-script section all setup fine but issue i was facing in bearer token setup in header. I want to read bearer token value from environment var and token value also correct and I have checked via console log but how i can use token value in header. If I pass whole token in header after bearer then it works but I want pass token value as var.
Here is the code-
const token=pm.environment.get('bearerToken');
url: url,
method: 'POST',
header: {
'content-type': 'application/json',
'Authorization': 'Bearer token',
'X-PB-AUTH-ISSUER' : 'psapi'
}
Upvotes: -1
Views: 38
Reputation: 1
Finally after spending hours found solution-
const token=pm.environment.get('bearerToken')
header:
{
'content-type': 'application/json',
'Authorization': 'Bearer '+token ,
'X-PB-AUTH-ISSUER' : 'psapi'
}
Upvotes: 0
Reputation: 314
you have to set you token in the postman authorization header and click </> icon on the right-side vertical bar then generate script for the request by choose your desire language.
Upvotes: 0