Describe the bug
I’d like to use variables in the request body but Postman didn’t accept that due to my pre-request authorization script, so I get 401 Unauthorized
error.
Any suggestions how can I fix that are very apreciated.
Request headers:
User-Agent:ApiRequestTask/1.0
Content-Type:application/vnd.api+json
Accept:application/vnd.api+json
Authorization:{{AuthorizationToken}};{{AuthorizationSignature}}
Request body:
{
"data": {
"type": "password_request",
"attributes": {
"email_address": "{{user.email}}"
}
}
}
Athorization pre-request script:
var secret = pm.environment.get("AuthorizationSecret");
var body = '';
var hash = '';
if(request.method == 'GET') {
hash = CryptoJS.HmacSHA256('', secret).toString(CryptoJS.digest);
} else {
hash = CryptoJS.HmacSHA256(request.data, secret).toString(CryptoJS.digest);
}
postman.setEnvironmentVariable("AuthorizationSignature", hash);
Screenshots
App information:
- App Type: Native App
- Postman Version: 6.1.4
- OS: macOS High Sierra 10.13.5