更新时间:2023-09-28 22:49:40
首先,创建一个环境(邮递员右上角-下图)这个不是我建议您为更好地处理变量而做的强制性步骤
At first, create an environment ( top right corner of postman - image below ) This is not a mandatory step by I suggest you to do for better handling of variables
我已经修改了脚本以满足您的需要
I have modified the script to suit your need
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("ID", jsonData.Location.split("?token=")[1]);
现在这将导出令牌的值(下面的屏幕截图)
Now this will export the value of the token ( screenshot below )
接下来你要做的就是调用请求#2中的变量
All you have to do next is to call the variable in request #2
这样您就不必每次都手动复制、粘贴到请求 #2 中