Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set environment variables by Postman

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces Postman how to set environmental variables, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Problem description

Set the environment variable, change the address accessed by the interface, such as localhost, and replace it with another IP address.

For example, there is an interface login

Local access is: http://localhost:8061/login

The test environment is http://11.11.11.136:8061/login

The IP address can be changed dynamically according to the environment, which needs to be solved by the environment variables in the Postman.

Solution idea

1: set up two environments in Postman, the local environment and the test environment

2: set a variable named base_url in the two environments to store the IP address of the respective environment

The way to get the value of an environment variable in Postman is: {{variable name}}, so that you can get the value of the variable.

Here, the value of base_url is obtained as follows: {{base_url}}

3: set to {{base_url}} / login in the URL address bar of Postman

4: switch different environments, the value of base_url will change, so as to achieve the effect of IP address switching.

Set environment variabl

Step 1: configure the button in the upper right corner of the picture

Click Manage Environmens, as shown below

I have set up two environments, so let's set up the third environment.

Step 2: 137 environment variables

Click the Add button, as shown in the following figure

Click Add to add successfully. What we want to explain here is that the above environment and the local test environment also have this base_url variable, but the value is different.

Is to switch the environment to take different base_ url values to achieve the environment switch.

As shown in the following figure, the environment variable has been added

Now that you have three environments, demonstrate how to switch and how effective it is.

Step 3: environment switching demonstration

As shown in the figure above: the environment can be switched in the upper right corner, and the value of {{base_url}} will change, which serves the purpose of switching the environment.

Thank you for reading this article carefully. I hope the article "how to set environmental variables in Postman" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report