0

I'm using postman for an api request. My question is; I'm getting an error when I made one of the variables random.

For example when I sent request this link;

https://testrest.xxxxxx.com/voucher/purchase/testAUD000/49/1/30000017/1 it is working. But when I change with this;

https://testrest.xxxxxx.com/voucher/purchase/testAUD000/49/1/30000017/{{transactionId}}

I'm getting this error; "You are not authorized to access this resource"

In my collection pre-request script;

var apiKey = pm.collectionVariables.get("API-KEY");
var apiSecret = pm.collectionVariables.get("API-SECRET");

var nonce = _.random(1, 50000000);
var signature = pm.request.method + "\n" + pm.request.url.getPath() + "\n" + nonce + "\n";
var hash = CryptoJS.HmacSHA256(signature, apiSecret).toString();

pm.request.headers.add("AUTHENTICATION: HMAC " + apiKey + ":" + hash + ":" + nonce);

I added this in collection pre-request script or request in pre-request script I'm getting error;

var random = Math.floor(Math.random() * 10);
pm.variables.set('transactionId',random)

0 Answers0