Reputation: 405
I am trying to replace the value of JSON Body in the Postman from environment variable, and the value is actually replaced but it converts the JSON into a string when passed to the POST request so the request eventually fails since the POST request expects JSON body..
For example, Here is the below request and the variables are already declared with values in the Postman
And once the request is sent, the entire body is converted to String. Any idea how to keep the body is JSON even after substituting the value for the variable and not let it convert to String?
Upvotes: 20
Views: 18997
Reputation: 504
Example, I have environment variable : variable name = port, initial value = 4242, current value = 4242. variable name = name, initial value = abcd, current value = abcd. To use environment variable as request body, use this in request body:
{
"string": "{{name}}",
"number": {{port}}
}
Upvotes: 23