Hey Postman community, I am new to the tool. I am looking for some help on setting current time dynamically on GET and POST requests with a HTTP “Date” format as Mon, 05 Jul 2021 06:23:40 GMT
Additionally, I would like to pass the resultant date into a Pre-requisite script that calculates HMAC-SHA256 digest. The HMAC operation should takes two inputs, a secret and a message. The message is constructed by concatenating the timestamp of the request, the HTTP verb used for the request, the method address of the request (including path and query parameters) and the request body if available.
Details (like screenshots):
I have tried the following and I have the request doesnt go through (status: 400 Request is too old)
I’ve already tried as part of pre-request Script
var timeStamp = new Date(); console.log(timeStamp.toUTCString()); postman.setEnvironmentVariable("timeStamp", Date); ////postman.setEnvironmentVariable("FinoaApiDigest", CryptoJS.HmacSHA256(request.data, 'Quixote de la Mancha').toString(CryptoJS.digest)); var sigString = environment.APIsecret + timeStamp var FinoaApiDigest = CryptoJS.SHA256(sigString); postman.setEnvironmentVariable("FinoaApiDigest", FinoaApiDigest);