JSON Stringify request body using raw

Hello,

We’re using API Gateway and the request body needs to be stringified before sending. Right now, I the request body with a json under “raw” and the content-type of application/json.

I’ve tried using:

var body = {
name: 'Test'
};

pm.environment.set('req_body', JSON.stringify(body));

Then passing in {{req_body}}, but it’s coming in as the whole stringified object as a key with an empty value.

Any ideas in this particular scenario how to get this to work in Postman?

Thank you

HI @davems

Could you give a bit more details please? I tried the following which seemed to work as expected

Pre-request script
image

Body
image

Console after sending (pretty)
image
or raw
image
(Note: Google replied with Error 405 (Method Not Allowed)!! as you’d expect.)