In HTTP client Editor on IntelliJ, I am trying to do this:
POST http://{{host}}/path-to-my-first-resource
Content-Type: application/json
{"field1":"false",
"field2":"test",
"field3":"test",
}
I got the result of the above POST with this:
> {%
client.global.set("my-first-returned-var", response.body.json.var1);
client.global.set("my-second-returned-var", response.body.json.var2);
client.global.set("my-third-returned-var", response.body.json.var3);
%}
The variables have been returned with success. Thus, I am trying to use those variables in a subsequent POST, like that:
POST http://{{host}}/path-to-my-second-resource
Content-Type: application/json
{"anotherfield1":"{{my-first-returned-var}}",
"justanother":"{{my-second-returned-var}}"
}
I tried to send the variables in the body with quotes and without quotes, but IntelliJ did not translate the variables inside double curlies. I can use the variables on HTPP Header, like:
GET https://my-request
Authorization: Bearer {{my-first-returned-var}}
But I could not use these variables in a JSON body.
The API that I'm trying to use is a Spring Boot REST Controller that use Jackson lib to deserialize the body from a request into a Java Object. The error message that Spring Boot return is something like that:
JSON parse error: Cannot deserialize instance of java.lang.String
out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException