Hi everybody!
Findout this great tool “Postman Flows”, but got problem with it.
I tried to use this in my project, set up authorisation chain, but i got stuck in send next request after authorisation.
In normal ways in last step in auth i get sessionkey and than in prerequest script next request i use this
// to replace all variables in {{...}} of the text object
function multiReplace(obj){
// console.log(obj);
if (~obj.indexOf("{{")) {
var var1, var1End, var1Name, var1Value;
var var1Start = -1;
while ((var1Start = obj.indexOf("{{", var1Start + 1)) != -1) {
var var1End = obj.indexOf("}}", var1Start) + "}}".length;
var var1 = obj.slice(var1Start, var1End);
var var1Name = obj.slice(var1Start, var1End).replace(/}}/, "").replace(/{{/, "").trim();
var var1Value = pm.variables.get(var1Name);
// console.log(var1Value);
obj = obj.replace(var1, var1Value);
}
}
// console.log(obj);
return obj;
}
var path = pm.request.url.getPathWithQuery();
// to get post-request path
path = multiReplace(path)
// console.log("path: ", path);
var body = pm.request.body.toString();
// to get post-request body
if (body) {body = multiReplace(body)};
// console.log("body: ", body);
var crypto = CryptoJS.enc.Base64.parse(pm.variables.get("SessionKey"));
// console.log("SessionKey: ", pm.variables.get("SessionKey"));
if (body.length) {
signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(path + '\n' + body, crypto));
} else {
signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(path, crypto));
}
console.log("signature: ", signature);
// Setting collection and environment variables
pm.collectionVariables.set("signatureHeader", signature);
and this signatureHeader generated in every request after auth and used in Headers.
Can anybody help and explain, how i can generate and use it in Postman Flows?