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.
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:
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"])
%}