当前位置:网站首页>Variable setting in postman
Variable setting in postman
2022-06-24 20:48:00 【m0_ sixty-two million four hundred and ninety-six thousand nine】
1. Variable ( overall situation / aggregate / Environmental Science )
Variables allow us to store and reuse their values in requests or scripts , By saving values in variables , You can assemble , Environment or request .
For us to do interface testing , Another very important function .
stay postman The three commonly used variables are global variables , environment variable , Set variable .
(1.) Global variables : Once global variables are declared , Global availability , in other words postman Any set in , This variable can be used in any request . Its scope is the largest .
(2.) environment variable : To declare environment variables , First of all, the creation environment , Then variables can be created in the environment . If you want to use environment variables , You have to choose first ( Import ) This environment , So you can use variables in this environment . It should be noted that the environment can also create multiple . There can be multiple variables in each environment .
(3.) Set variable : Set variables are set specific , That is to say, the declared variable must be based on a collection , Its scope of use is only valid for this collection .
Their scope ranges from large to small : Global variables > Set variable > environment variable . When the same variable is declared in several different scopes , The smallest variable will be used in priority to make .
To use a value in a variable, simply 2 A step , They are defining variables and getting variables .
Defining variables ( Set a variable )
Get variable ( Access variables )
Define global variables and environment variables , Click the pinion in the upper right corner to pop up the following interface , You can define global variables or environment variables according to requirements .

Global variables and environment variables that have been defined , You can do a quick look
Define set variables
Select a collection , Open to see more actions (...) menu , Then click Edit . choice “ Variable ” Tab to edit or add to collection variables
Get variable Define variables , Then you can use variables . It should be noted that , Get variables in different places , The rules of writing are also different .
If you get the variable in the request parameter , Whether it's getting global variables , Or environment variables , Or set variables , The way to get it is the same writing rules :{ { Variable name }}
The request parameters refer to :URL,Params , Authorization , Headers , Body
Get environment variables :pm.environment.get(‘ Variable name ’)
Get global variables :pm.globals.get(' Variable name ')
Get collection variables :pm.pm.collectionVariables.get.get(' Variable name ')
If it's where the code is written (Tests,Pre-requests Script) Get variable , Get different types of variables , The code is different , As follows :

Variables are used in a wide range of scenarios , For example, we will talk about Interface Association later , Variables are used in the pre request script
边栏推荐
- Agency mode -- Jiangnan leather shoes factory
- Dx12 engine development course progress - where does this course go
- How to apply agile development ideas to other work
- Selenium crawl notes
- 【建议收藏】时间序列预测应用、paper汇总
- Leetcode(146)——LRU 缓存
- Memo mode - game archiving
- C語言實現掃雷(簡易版)
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
- Haitai Advanced Technology | application of privacy computing technology in medical data protection
猜你喜欢

More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention

伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI

Bean lifecycle flowchart

Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month

Stackoverflow annual report 2022: what are developers' favorite databases?

两位湖南老乡,联手干出一个百亿IPO

苹果、微软、谷歌不再掐架,今年要合力干一件大事

Byte and Tencent have also come to an end. How fragrant is this business of "making 30million yuan a month"?

The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"

Leetcode(135)——分发糖果
随机推荐
微信小程序中使用vant组件
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
Dx12 engine development course progress - where does this course go
When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
宅男救不了元宇宙
Interpreter mode -- formulas for dating
The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
Leetcode(146)——LRU 缓存
VXLAN 与 MPLS:从数据中心到城域以太网
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
Otaku can't save yuan universe
Summary of idea practical skills: how to rename a project or module to completely solve all the problems you encounter that do not work. It is suggested that the five-star collection be your daughter
Prototype mode -- clone monster Army
字节、腾讯也下场,这门「月赚3000万」的生意有多香?
Camera rental management system based on qt+mysql
Background of master data construction
Enjoy yuan mode -- a large number of flying dragons
16 excellent business process management tools
Popupwindow touch event transparent transmission scheme
Leetcode (455) - distribute cookies