使用Postman将请求参数传递到环境变量

时间:2019-09-18 11:42:26

标签: json rest postman

我正在尝试在发送请求之前将环境变量中的值提取为参数值,并在请求发送后将值附加1并使用邮递员传递给环境变量

Pre-Req脚本:

var TranscationID ;
postman.setEnvironmentVariable("TranscationID", TranscationID);

测试脚本:

var TranscationID = JSON.parse(requestBody);
postman.setEnvironmentVariable("TranscationID",TranscationID.request.TranscationID.toInt+1);

试图将其传递给transcationID字段:

 "AccountStatus": "Open",
 "TransactionID": "{{TranscationID}}",

收到错误:

There was an error in evaluating the test script:  ReferenceError: requestBody is not defined

0 个答案:

没有答案