Postman Tutorial Part 14 – Create, Manage and Use Global Variable In Postman

Hello folks,

We have already seen creating, managing and using environment variables in Postman.

We can select only single environment at a time in Postman and can use variables of that selected environment. We may have some variables which are common to each environment. It is not good practice to keep a separate copy of each common variable in each environment. It will not be a good architectural design.

Postman has something called Global variables which are available globally in fact at any scope. You can use global variables with or without selecting any environment. You can use global variables wherever you can use variables of an environment. Remember global variable does not belong to any specific environment.

Enough of theory, let’s create global variables:-

  1. Click on “Manage Environment” icon at right top corner of Postman tool.

2. You will see below screen:

3. Click on “Global” button. Pass the desired variable’s name and it’s an initial value. Process is same as creating an environment variable. Only difference is that here you do not provide Environment name.

4. Click on Save button. You can see all variables ( Environment and Global) by clicking on “Environment quick look” icon.

5. You can quickly edit variables by clicking on provided edit button as well. Save button will be enabled as soon as there is any unsaved changes.

Accessing any global variable:-

To use any global variable, it is not mandatory to choose any environment in drop down. We just need to use variable name as placeholder {{variableName}}. This placeholder will be replaced with its current value. For example: – {{URL}} will be replaced by “ ” from the declared global variable named “URL”.

You can see value by mouse hovering on {{URL}}.

Remember variable name is case sensitive. URL and url are two different variables.

Important point to remember:-

Environment variable will take precedent always on global variable if found in both scope. If a selected environment has a variable which is also available in global scope, variable from environment will take precedence.

More about API Testing in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

Leave a Reply

Your email address will not be published. Required fields are marked *