Horje
Edit and set environment variables in Postman

In Postman, the “environment” refers to a set of key-value pairs or a collection of variables used to customize requests. Environments allow you to define variables that can be reused across multiple requests, making it easier to manage different configurations for testing APIs or web services.

Features of Environment Variables:

  • Variables: It allows us to define and store variables, such as URLs, authentication tokens, API keys, etc. These variables can be used across multiple requests within the same environment, making it easy to manage and update them centrally.
  • Scope Control: Variables in environments can have different scopes, such as global or environment-specific.
  • Environment Switching: Postman provides a simple interface for switching between different environments. This allows us to quickly change the configuration of our requests based on the environment we are testing.
  • Security: Postman environments support encrypted variables, ensuring sensitive information such as passwords or API keys are securely stored and transmitted.

Implementation of Environment Variables :

1. Setting environment variable :

Step 1: Create a request in a collection. In below image localhost may vary depending on development, testing, staging, and production. So, we can use the environment variable here.

Screenshot-2024-03-07-005527

Step 2 : In left-hand side of the Postman interface, you’ll see a menu labeled “Environments“. Click on “Create Environment“.

Screenshot-2024-03-07-010044

Step 3 : A tab will gets opened and we can add new variables, their types and values. Save the environment after adding all the variables.

Screenshot-2024-03-07-010627

Step 4: Use the variables in request and choose environment from top right corner “No Environment“.

Screenshot-2024-03-07-010925

Step 5 : Run the request and we will get the results as per our variable.

Screenshot-2024-03-07-011335

2. Editing an environment variable.

Step 1: Open the environment and update the variables (Here we can see that we have not added port 3000 in baseUrl variable, so let us edit this variable).

Screenshot-2024-03-11-115116

Step 2: Save it and then run the request again against the choosen environment (GFG Env).

Screenshot-2024-03-11-115319

Output :
lv_0_20240311140140




Reffered: https://www.geeksforgeeks.org


Web Technologies

Related
What are Request Parameters in Postman ? What are Request Parameters in Postman ?
How to Send WebSocket Requests with Postman ? How to Send WebSocket Requests with Postman ?
How to send Multiple Requests at same time in Postman ? How to send Multiple Requests at same time in Postman ?
How to save Request & Response result as a File in Postman? How to save Request & Response result as a File in Postman?
Design a Correlation Coefficient Calculator Template in Tailwind CSS Design a Correlation Coefficient Calculator Template in Tailwind CSS

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
14