接口测试 postman 怎么提取接口返回值,以便其它接口使用

sunchuanxin · May 31, 2017 · Last by sunchuanxin replied at June 01, 2017 · 3040 hits

postman 怎么提取接口返回值,以便其它接口使用,求例子

共收到 2 条回复 时间 点赞

在 test 中将你要提取的值设置为环境变量,使用 postman.setEnvironmentVariable(variableName, variableValue)。
然后在要使用的接口中直接使用该环境变量即可,调用环境变量使用{{variableName}}

搞出来的示例
tests 中填写
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("prd", jsonData.data[0].ip);
值的部分不要加引号

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up