postman association

Enter the script in Tests

var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("message", jsonData.code);

Get the value of message in the response data, such as: The response data is directly {"code": 0} so the script is jsonData.message

 

 Where to step on the pit:

The script here depends on the return form of the response to modify

Such as:

var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("uid", jsonData.result .uid); Here the format returned by the response is result and there are arrays in it, so the script to get uid is jsonData.result.uid

  

When obtaining the associated parameters, you can set an environment, put the obtained value in it, and call it for the next request. If the environment is not set, it seems that the obtained parameters are not saved to the

 

 

 


After obtaining the corresponding value, the reference is written:

uid={{code}}

 

Reference: https://testerhome.com/topics/7614

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324765321&siteId=291194637