I’m trying to authorize to Hotelbeds API https://developer.hotelbeds.com/, but script is not working.
Requirement for authorization " To authenticate, you must send both the API Key and the X-Signature , a SHA256 hash in Hex format calculated from your API key, your secret plus current timestamps in seconds":
I am using script:
var Apikey = “xxx”;
var secret = “xxx”;
var d = new Date();
var timestamp = d.getTime();
var hash = Apikey + secret + timestamp;
console.log("hash :: " + hash);
var signature = CryptoJS.HmacSHA256(request.data, hash).toString(CryptoJS.digest);
var signature = CryptoJS.SHA256(hash).toString();
pm.request.addHeader({
key: ‘X-Signature’,
value: signature
});
console.log("Signature :: " + signature)