What are environments?
While working with APIs, you will often need to have different setups. For example, your local machine, the development server, or the production API. Environments give you the ability to customize requests using variables. This way you can easily switch between different setups without changing your requests. You won’t have to worry about remembering all those values once they are in Postman. Environments can be downloaded and saved as JSON files and uploaded later.
Steps to create a new environment
Click the gear icon in the upper right corner of the Postman app and select Manage Environments.
Click the Add button to create a new environment.
Provide Environment name Like Local/Development or Production.
Each environment is a set of key-value pairs, with the key as the variable name.
e.g Here we create two keys which can be used while triggering API’s
API_URL
APP_VERSION
We can also set global variables which can be accessible in all the environments
Set Key Values as set earlier while creating an environment and then click on save button.
Steps to use environment
Select an active environment
Click the drop-down in the upper right corner of the Postman app to select an active environment, or type in the environment name. Once you select an environment, you can access variables within the active environmental scope.
Access Environment Variables
After selecting the environment you can easily access the variable in Body, Headers or in Request URL.
Note: The variable name will be enclosed in double curly braces. e.g {{API_URL}}. You can also get the suggestion of variable by typing single curly braces ‘{‘
In the below screenshot we have used variables in Request Url and in Body parameters.
Note: Environment and global variables will always be stored as strings. If you�re storing objects/arrays, be sure to JSON.stringify() them before storing, and JSON.parse() them while retrieving.
For any queries, please feel free to reach us at support@knowband.com.
You can also take a look at the best eCommerce modules provided by Knowband for Prestashop, Opencart, Magento and Magento 2.
Check out our top selling Modules:
Prestashop Android and iOS Mobile App Builder Addon