Code Snippets #3 – Environment Variables

posted in: Software Testing | 1

Environment variables are a great way to store data to not only use to post requests but also to compare against returned values. 

The main command is

postman.setEnvironmentVariable("Variable_Name", <value>);

To re-use a saved variable, use the prefix environment. before the saved variable name. 

environment.variable_name

To use the variable in the url or headers, put the name of the saved variable in braces 

{{variable_name}}

and that’s about it. 

Very simple, but also very powerful allowing you to change a re-used variable in one place which is the Manage Environments which is accessible through the gear icon to the top right of postman. 

For more information, see the postman documents: Postman documents on Environment Variables.

 

Back

One Response

  1. […] Postman you can set environment or global variables. What are these you might ask? Well, if for example you use the same email address throughout all […]

Leave a Reply