JSON Stringify request body using raw


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

1 Like

HI @davems

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

Pre-request script


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

For future user’s landing on this issue:

Make sure your request body is only this (no quotes around the variable name, otherwise it’ll get converted to a string):


and not this: