postman interface test six

table of Contents

Reference

Postman requests automatic token acquisition

Add an environment

Add login interface

Add a collection

Add a request that requires a token


Reference

  • Main reference: Github: api_tool_postman

  • Manage environments

  • postman-variables/environment/filtering, etc.-简书

  • Postman Manual 3-Environment Variables-简书

  • Postman use four: switch environment and set read variables-乔叶叶-博客园

Postman requests automatic token acquisition

 

Add an environment

Manage Environments(右上角的齿轮) => Add => 填写环境的名称 => Add
  • 1

Add login interface

# 比正常的请求多设置一下 "Tests"
# 将登录接口返回的response中的token加入环境变量, 如:
pm.environment.set("token", JSON.parse(responseBody).data.authorization);
  • 1

  • 2

  • 3

Add a collection

1. New collection (左侧 目录) 
2. 填写名称,如:"需要token的请求" 
3. 切换到选项卡"Authorization"
4. 选择相应的 TYPE
5. Token 中填写 {
   
   {token}}
6. 点击Create 创建集合
  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

Add a request that requires a token

For requests added to the newly created collection, the token will be automatically added to the header. If the token fails, just request the login interface again.

Guess you like

Origin blog.csdn.net/weixin_37018468/article/details/106193475