How to set a global variable in Postman?


The global variables can be accessed by all the Environments and is available for every request. To set a global variable follow the below steps −

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.

Step3 − Now, select a different Environment and see if the Global variable url is accessible. Here, we have two different Environments - Environment_Test and Mock Server.

Step4 − First select the option Environment_Test and add {{url} in the address bar. On hovering over it, we shall show the letter G(meaning global) and the SCOPE as Global.

To use an Environment variable in a request we have to enclose it with double curly braces {{<Global variable name>}}.

Step5 − Select the option No Environment and add {{url} in the address bar. On hovering over it, we shall see the letter G(meaning global) and the SCOPE as Global.

Thus we find that the Global variables can be accessed from any Environments. In Postman, if we have the same variable name added to the Global and Environment (Local) variable, then the preference is given to the local variable.

Updated on: 25-Jun-2021

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements