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?
Let's say you have to pass an integer number from 1 to 1000, so for that, you need to add {{$randomInt}}. Like the above example of the number variable, Postman supports so many other dynamic variables as well.
You can access your environment variables from Postman and from your request elements, including the URL, parameters, body data, and test scripts.
To set up Postman environment variables: In the top right corner of Postman, click the environment selector and select Manage environments. Click Add to add a new environment where you'll define your OneLogin environment variables. Note: You'll need to use your API credentials to generate the access_token value.
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}}
}
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