Open the "Add variable to JSON body" request and notice how we're using the pre-request script to change the value of the variable present in the body right before the request is being sent.
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
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.
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}}.
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"]}
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With