Reputation: 1517
I am trying to chain my rest apis in postman.After one of the api gets executed i saved 2 variables in environment using:
postman.setEnvironmentVariables("x","xValue");
postman.setEnvironmentVariables("y","yValue");
Now i need these 2 variable to be passed as json in next api. I am passing this as follows:
But values are not getting passed not as expected.Values is still being passed as "{{xValue}}" instead of some Value.
Can somebody help if i am doing something wrong.
Thanks,
Upvotes: 0
Views: 422
Reputation: 1004
You are using an undefined variable {{xValue}}
inside your request body, that is why it's just returning this string. If you change it to {{x}}
--> you will get the output xValue
.
For example:
// set environment variable named "variable_key"
pm.environment.set("variable_key", "variable_value");
// access environment variable named "variable_key" in your request body
{
"someKey": {{variable_key}}
}
Postman Test Examples
https://learning.getpostman.com/docs/postman/scripts/test_examples/
Upvotes: 3