Intellij HTTP客户端保存JSON值作为变量不适用于可变名称的可变名称
我的获取请求:
GET {{Endpoint}}/tokens/v1/id
Content-Type: application/json
> {% client.log(response.body.no-claim); %}
响应正文:
{
"documentation": "roofs",
"no-claim": "eyJ0eXAiOiJKV1QiLCJhbGc"
}
响应处理程序的错误:
ReferenceError: "claim" is not defined. (<jsHandler script>#143)Script finished
如果我尝试提取文档的值,它可以正常工作,但不适用于“无主张”。
我尝试将其包装在单个/双引号中,并将其保存到Env变量并将ENV变量作为{{not-claim}}传递给ENV变量,它们都无法使用。
My GET Request:
GET {{Endpoint}}/tokens/v1/id
Content-Type: application/json
> {% client.log(response.body.no-claim); %}
Response body:
{
"documentation": "roofs",
"no-claim": "eyJ0eXAiOiJKV1QiLCJhbGc"
}
Error from Response handler:
ReferenceError: "claim" is not defined. (<jsHandler script>#143)Script finished
If I try to extract value of documentation it works fine but not working for "no-claim".
I tried wrapping it within single/double quotes and also saving it to env variable and passing the env variable as {{no-claim}}, none of them worked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是JavaScript。您可以使用响应。Body['id-claim']语法。 https://developer.mozilla.org/en-us/docs/web/javascript/referent/referation/property_accessors#syntax
例如,下一个请求正常:
It is JavaScript. You can use response.body['id-claim'] syntax. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#syntax
For example, the next request works fine: