In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Today, when we do the interface test, the parameter of one interface is a check token, which will be updated in real time. The developer provides an API that returns real-time token separately, so you need to call the return value of token API when the functional interface is used as the parameter of the functional interface.
I searched the Internet and found no ready-made instructions. I just studied it, so I wrote down the steps for the convenience of the students behind.
If the return value of the interface of token is in the standard JSON format, it is a simple two-step process.
1.token API sets global variables
The first step is to execute the token interface and assign the token value in the interface return value to a global variable.
The assignment operation is written in Tests and the content is as follows:
Var jsonData = JSON.parse (responseBody); pm.globals.set ("token", jsonData.token)
Here is a screenshot of my settings:
two。 Call global variables in function interface parameters
The second step, of course, is to get the value of the global variable set above as an input parameter to the function interface.
The acquired implementation is written to Pre-request Scripts and implemented as follows:
Pm.globals.get ("token")
At the same time, to set the Params of the interface, add a Key,Key whose name is the name of the parameter, and the content of Key is the global variable name, such as {{token}}.
Here is a screenshot of what I have set up:
3. Sequential execution of interface calls
When the setting is complete, just call the token interface first, and then call the functional interface. Pay attention to the execution order here, if the reverse is true, the interface call will fail.
In addition, if the global variable set by the token interface takes effect, we can also view the specific Globals information through the entry provided by the tool, such as:
OK, the simplest operation steps are mentioned above, and there may be some other situations. For example, when the return value of API token is not standard JSON, you also need to deal with the return value. For example, some students do not want to set global variables, so you need to configure an environment variable in advance for use, and so on.
There are more surprises waiting for us to discover.
This article was first posted on the official account "sylan215", ten years to test the original practical information of veterans, follow me, rise posture!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.