Postman associated interfaces Test (with authentication token)

Postman associated interfaces Test (with authentication token)

A landing Interface

  1. Creating a request Request
  2. Add JavaScript code in the Tests, to acquire an authorization
pm.test("V2", function () {
    //jsonData:响应的所有json信息
    var jsonData = pm.response.json();
    var token = jsonData.data.token;
    //将token值添加到token环境变量中
    pm.environment.set("token",token)
});

Second, the environment variable is added while getting registered in the cash value token interface

Add Authorization request header attribute, attribute value token value

Get token value of the environment variable, for obtaining a {} {}

Click to send successful operation

Guess you like

Origin www.cnblogs.com/desireyang/p/12035759.html