Intellij Idea HTTP 请求负载变量

发布于 2025-01-19 08:32:47 字数 1148 浏览 1 评论 0原文

问题 Intellij Ideas HTTP-Request Post具有有效载荷值取决于环境。例如,在有效载荷中使用时,变量无法代替路径变量。

JSON解码错误:未识别的令牌'test':正在期待(JSON字符串,数字,数组,对象或doken'null','true'或'false');嵌套异常是com.fasterxml.jackson.core.jsonparseexception:未识别的令牌'test':正在期望(json字符串,数字,数字,数组,对象或doken'null',true'or'或false'或false''或false') (io.netty.buffer.bytebufinputstream)

research https://www.jetbrains.com/help/idea/http-client-reference.html

http-client.env.json

{
 "LOCAL": {
  "protocol": "http://",
  "host": "localhost",
  "port": ":8000",
  "apiKey": "api-key",
  "username": "[email protected]",
  "password": "password"
  }
}

  • Intellij 2021.2.1
  • 您可以从上下文菜单中选择有效负载变量,并使用CTRL +单击

问题有没有办法在有效载荷中使用变量?

PROBLEM Intellij Idea HTTP-request POST has payload values dependent on an environment. Variables are not substituted when used in a payload as they are in place of path variables, for example.

JSON decoding error: Unrecognized token 'test': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'test': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (io.netty.buffer.ByteBufInputStream)

RESEARCH https://www.jetbrains.com/help/idea/http-client-reference.html

http-client.env.json

{
 "LOCAL": {
  "protocol": "http://",
  "host": "localhost",
  "port": ":8000",
  "apiKey": "api-key",
  "username": "[email protected]",
  "password": "password"
  }
}

https://i.imgur.com/OKzE8pP.png

  • Intellij 2021.2.1
  • you can select payload variables from context menu and navigate with Ctrl + click

QUESTION Is there a way to use variables in a payload?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花期渐远 2025-01-26 08:32:47

玩了一段时间并重新阅读异常后,我猜测将其用双引号引起来。现在它可以工作了:

在此处输入图像描述

After playing some time and rereading the exception, I've had a guess to wrap it into double quotes. Now it works:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文