How to Use Environments in Postman?

How to Use Environments in Postman: A Step-by-Step Guide | Knowband

What are Environments?

When working with APIs, you will often need to have different configurations. For example, your local machine, the development server, or the production API. Environments provide the ability to customize requests using variables. This way, you can easily switch between different settings without changing your requests. You won’t have to worry about remembering all these values once they’re in Postman. Environments can be downloaded and saved as JSON files and loaded later.

what are environments - explain by Knowband

Steps to Create a New Environment

Click the Environments section in the left menu.

Click the Add button or Create Environment to create a new environment.

Screenshot of getpostman

Click the Add button to create a new environment.

Click the Add button to create a new environment

Provide the environment name such as local/development or production.

Each environment is a set of key-value pairs, with the key as the variable name.

for example, here we create two keys that can be used when triggering APIs

API_URL

APP_VERSION

Manage environments and new one

We can also define global variables that can be accessible in all environments. Click on the global button. 

Set the key values as previously defined when creating an environment and click the save button.

when creating an environment and click the save button

Steps to Use Environment

Select an active environment

Click the drop-down menu in the top right corner of the Postman app to select an active environment, or type the environment name. After selecting an environment, you can access variables in the scope of the active environment.

screenshot of active environment

Access Environment Variables

Once you’ve chosen the platform, you can easily access the variable in the Body, Headers, or Request URL.

Note: The variable name will be enclosed in double braces. for example, {{API_URL}}. You can also get the variable suggestion by typing simple braces ‘{‘

In the screenshot below, we have used variables in Request Url and Body parameters.

screenshot of body parameters

Note: Global and environment variables will always be stored as strings. If you are storing objects/arrays, be sure to JSON.stringify() before storing them and JSON.parse() during retrieval.

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

Android and iOS App Maker for Opencart

One Page checkout addon for Prestashop

Knowband Mobile App Builder Module

Knowband Mobile App Builder

Get the mobile app created for your store in a few hours with the Knowband Mobile App Builder Module.

Learn More

Joe Parker

We boast of the best in the industry plugins for eCommerce systems and has years of experience working with eCommerce websites. We provide best plugins for platforms like - Magento, Prestashop, OpenCart and Shopify . We also provide custom module development and customization services for the website and modules..

Leave a Reply

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