1

I'm trying to run a request that uses the request body for md5 encryption. When I'm using an environment variable in my body using {{var}} format I get an MD5 validation error whereas hardcoding the variable into the request body works. Is there any way to parameterize the variables into the body? The pre-request script is given below:

const req = pm.request;
var bodymd5 = CryptoJS.enc.Base64.stringify(CryptoJS.MD5(req.body.toString()));
var h = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key).update(req.method).update(req.url.getPath()).update(ctype).update(date).update(bodymd5).update(id).update(nonce).finalize();
Adharsh V S
  • 95
  • 11

1 Answers1

1

I got my answer. Here is what I did:

var req = pm.request;
req.body.raw = (req.body.raw).replace("{{order_no}}", pm.environment.get("order_no"));

The above code allowed me to replace what I wanted with the environment variable.

Adharsh V S
  • 95
  • 11