I guess there’s some other issue with the script / the variables not being set properly, because irrespective of the type of request body, the variables will always get resolved.
I have a odd scenario where a 3rd party API I need to POST to, requires a request body text/plain. I did a pre-request script of: let authKey = pm.collectionVariables.get(“authn”); console.log('var: ’ + authKey); # Shows a valid value pm.collectionVariables.set(‘reqBody’, authKey);
And my body is raw/text with a placeholder of: {{reqBody}}
But when I POST, the body ends up being blank e.g. my token is not replaced. What am I doing wrong?
What is being sent in the body of the request? Does it show anything in the console logs if you expand out the request body section?
It also looks like you are retrieving an collection variable called authn and then not doing anything with it before resaving it as another collection variable. Why can’t you just use the original collection variable?
Finally, you might want to check the Content-Type header to ensure that is not causing you issues.