我的 GET 请求:
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
如果我尝试提取文档的价值,它工作正常,但不适用于“无索赔”。
我尝试将其用单/双引号括起来,并将其保存到环境变量并将环境变量作为 {{no-claim}} 传递,但没有一个起作用。
它是 JavaScript。您可以使用response.body['id-claim']语法。 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#syntax
例如,下一个请求工作正常:
POST https://httpbin.org/post
Content-Type: application/json
{
"my-json-value": "value"
}
{%
// 'json' is a property in HTTPBin response JSON
client.log(response.body.json["my-json-value"])
%}