I'm working with Postman right now and I have to do a lot of requests, and in the body
I'm passing a JSON content. I would like to know if is there a way to pass the value of a global variable into JSON body. Thank you.

- 961
- 2
- 10
- 22
5 Answers
If using a raw JSON body:
{
"test key":"{{global variable}}"
}
On sending the request, the curly braces will be replaced with the value of the variable.

- 891
- 7
- 9
-
1How do you replace the ENTIRE POST Body with a variable? I tried raw body with only `{{varName}}`,but its not highlighted in Postman nor accepted from the service. – SeaDude Oct 24 '19 at 04:47
I think what you want to do is described here.
To use a variable you need to enclose the variable name with double curly braces – {{my_variable_name}}.

- 721
- 7
- 22
Double curly bracket is working in header parameter, url or inside JSON body. Inside tests you should use globals
example: {"url": globals.url}
or {"url": globals["url"]}

- 155
- 2
- 5
Yep, double curly brackets is the way to go to achieve this - make sure you have the latest version of Postman (though if you are still running 2014 code when this feature was introduced, shame on you!)
eg:
{
"variable": "{{value}}"
}
See the second paragraph here in the Variables section of the documentation - it specifically mentions the request body
.

- 443
- 1
- 6
- 14
You can pass
{
"productId": {{**ProductID**}},
"quantity": 1
}
Where ProductID is your global variable name
in raw format JSON (application/json)

- 2,351
- 10
- 23
- 28

- 77
- 1
- 4
-
I'm not sure why this works, but it does. I was following the official documentation and a bunch of other answers on stackoverflow and other forums, everything says to just use double quotes around your variable (along with the double curlies). This kept giving me errors. As soon as I added the double asterisks it started working. – Damian Esteves Apr 28 '22 at 19:01