当前位置:网站首页>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
边栏推荐
- What will you do if you have been ignored by your leaders at work?
- 首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
- Stackoverflow annual report 2022: what are developers' favorite databases?
- With its own cells as raw materials, the first 3D printing ear transplantation was successful! More complex organs can be printed in the future
- Coinbase will launch the first encryption derivative for individual investors
- Predicate
- C語言實現掃雷(簡易版)
- What are the problems with traditional IO? Why is zero copy introduced?
- Interpreter mode -- formulas for dating
- I just purchased a MySQL database and prompted that there are already instances. The console login instance needs to provide a database account. How do I know the database account.
猜你喜欢
随机推荐
伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
What will you do if you have been ignored by your leaders at work?
Builder mode -- Master asked me to refine pills
Leetcode(455)——分发饼干
Behind Tiantian Jianbao storm: tens of millions in arrears, APP shutdown, and the founder's premeditated plan to run away?
等保备案是等保测评吗?两者是什么关系?
The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
Map跟object 的区别
“拯救”直播带货,一个董宇辉还不够
云计算发展的 4 个阶段,终于有人讲明白了
Simulation lottery and probability statistics experiment of the top 16 Champions League
The Google File System (GFS) learning notes
消息称腾讯正式宣布成立“XR”部门,押注元宇宙;谷歌前 CEO:美国即将输掉芯片竞争,要让台积电、三星建更多工厂...
C language to realize mine sweeping (simple version)
Responsibility chain mode -- through interview
Image panr
图的基本概念以及相关定义
微信小程序自定义tabBar
opds sql组件能不能将流程参数通过上下文传给下一个组件
【建议收藏】时间序列预测应用、paper汇总









