Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using environment variables in POST payload

Tags:

postman

Can I use environment variables set in a previous test in the payload I am posting?

eg.

POST /list

{
    "some_key": environment.saved_value
}
like image 863
shapeshifter Avatar asked Dec 31 '14 01:12

shapeshifter


People also ask

Can we import environment variables in Postman?

Importing Postman Environments​ Click to open one of your Projects. Click the Vault tab. Click Variables. Click Import.

How do I add environment details to my Postman?

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.

How do you use global variables in Postman?

Step1 − Click on the eye icon beside the No Environment dropdown and then click on the Edit link within the Globals section. Step2 − MANAGE ENVIRONMENTS pop-up opens up. Here, we have added the variable url and the value as https://www.tutorialspoint.com/index.htm. Click on Save then close the pop-up.


1 Answers

Yes, you can do that. You send it up like this

{ 
    "some_key" : "{{environment_variable_name}}"
}

So, if in your previous test you had set it with something like

postman.setEnvironmentVariable("id","some_value")

You can use it in your POST with

{ 
"some_key" : "{{id}}" 
}

Hopefully, that answers your question

like image 73
moorecats Avatar answered Nov 11 '22 04:11

moorecats