输入参数可以传递到 httpyac 文件吗?

问题描述 投票:0回答:1

我希望将输入参数从命令行传递到 httpyac 文件。具体来说,我想以这样的方式调用 httpyac 文件,以便我可以传递 id 参数并在 httpyac 文件中访问它。这是我当前如何调用 httpyac 文件的示例:

httpyac ./seeds/fill.http --all --var id=0

在 fill.http 文件中,我尝试使用以下语法检索 id 参数:

{{+
  exports.defaultHeaders = {
    'Content-Type': 'application/json',
  };
}}

@id={{$0}}

我希望获得有关如何正确构建此调用并在 .http 文件中检索 taskId 参数的指导。

rest http request command-line-arguments
1个回答
0
投票

您已经使用 id 变量调用您的 http 文件。您不需要再次定义它

  1. 创建一个名为 test.http 的文件
GET https://httpbin.org/anything?foo={{foo}}
  1. 执行命令行
httpyac test.http --all --var foo=bar
© www.soinside.com 2019 - 2024. All rights reserved.