Place this script at pre-request-script and environment.secret is stored in environment variables or pass hardcoded here.
It will convert HMAC(.SHA256, /URI + /Body) and place into a global variable name as signature. which can pass on header like: x-pch-digest:{{signature}}
See the images::
It will convert HMAC(.SHA256, /URI + /Body) and place into a global variable name as signature. which can pass on header like: x-pch-digest:{{signature}}
var index = request.url.indexOf('/'); var uri_path = request.url.substring(index); var payload = uri_path + request.data; console.log("Using payload as " + payload) var hash = CryptoJS.HmacSHA256(payload, environment.secret); var hashInBase64 = CryptoJS.enc.Hex.stringify(hash); postman.setGlobalVariable("signature", hashInBase64);
See the images::
No comments:
Post a Comment