I'm testing an api that i have to send in body those data acording to documentation:
studentId,
apiKey,
timeStamp (current iso time as a string),
messageSignature: apikey+studentId+timeStamp encrypted using sha256,
i wrote a script to generate message signature using sha256 in Pre-request Script. Pre-request Script:
var dateIso = new Date().toISOString();
pm.globals.set("isoDateTostring", dateIso);
console.log('timestamp var is:', pm.globals.get("isoDateTostring"));
let msg = "apiKeyvalue" + "studentId" + pm.globals.get("isoDateTostring");+ JSON.stringify(msg)
const hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, "secretKey");
hmac.update(msg);
const messageSignature = hmac.finalize().toString();
Details (like screenshots): in body i wrote:
{
"studentId":"********",
"apiKey":"************",
"timeStamp":{{$isoDateTostring}},
"messageSignature": {{$messageSignature}}
}
when i send the request i get base64 is notdefined.