Postman API - 将环境变量传递给另一个请求jason body

时间:2017-10-24 21:44:02

标签: postman

  1. 我创建了全局变量。将其设置为Test,因为env可变对应的引用ID存储在CreateGLVar
  2. pm.test("Status code is 200", function () { pm.response.to.have.status(200);}); var jsonData = pm.response.json(); pm.environment.set("CreateGLVar",jsonData.result.quoteID);

    脚本,用于将值存储在Env变量

    1. 我可以知道如何使用存储在CreateGLVar中的值作为以下脚本。我如何从全局变量的第一个请求中引用id,并在第二个请求中动态插入(如下所示)。
    2. get quote id

      enter image description here

2 个答案:

答案 0 :(得分:3)

Postman使用双花括号来插入变量,也可以在原始请求体中使用。

在您的具体情况下,您可以使用:

"quoteID": "{{quoteIdVariable}}"

我使用的是Postman Chrome扩展程序5.3.1版,这对我有用。

编辑:既然Chrome扩展程序已被删除,这仍适用于Postman桌面应用

答案 1 :(得分:0)

谢谢Aaron。

当我使用" quoteID":" {{quoteIdVariable}}"我的绑定API.my 2 API在我单独执行时工作正常。

但是当我将API作为集合(Quote和Bind API)执行时,我遇到了问题。如果我作为集合执行,我在这里失踪了。

enter image description here enter image description here

Execution failed 失败enter image description here

相关问题