将token接口中返回的access_token设置为全局变量。

如:token接口返回格式为:

{
"data": {
"access_token": "xxx",
"expires_in": xxx
},
"err": 0,
"msg": "success"
}

js脚本为:

var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("Auth",jsonData.data.access_token);

test断言:

tests["msg"] = jsonData.msg === "success";
tests["Status code is 200"] = responseCode.code === 200;

postman提取返回值和断言

 

相关文章:

  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2021-06-11
  • 2022-12-23
  • 2022-01-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案