I just ran into this problem and cannot understand why this is happening.
code snippet client:
try {
ResponseEntity<Credentials> response = this.restTemplate.exchange(uri, HttpMethod.POST, httpEntity,
Credentials.class);
this.userCredentials = response.getBody();
return this.userCredentials;
} catch (HttpStatusCodeException hsce) {
logger.error("loginUser failed with code " + hsce.getMessage());
ObjectMapper mapper = new ObjectMapper();
TransmissionFailureException tfe = new TransmissionFailureException();
try {
if (hsce.getStatusCode() == HttpStatus.UNAUTHORIZED) {
logger.warn(" HIER " + hsce.getMessage());
throw (CredentialsIncorrectException) mapper.readValue(hsce.getResponseBodyAsString(), CredentialsIncorrectException.class);
...
When I install HttpMethod in GET (of course, on the server side), hsce.getResponseBodyAsString () returns a JSON representation of my error as String, as expected, and Parsing / Mapping works as expected.
It is strange that the same request made using SoapUI has an exception in the body, as expected in POST and GET.
Am I misunderstood something or is this some kind of mistake?
Any help would be appreciated.
Yours faithfully
Edit: Json Body displayed by Soap UI using GET:
{
"cause": null,
"stackTrace": [
...
],
"localizedMessage": "No user found with given username...",
"message": "No user found with given username...",
"suppressed": []
}
Json Body displayed by Soap user interface using POST:
{
"cause": null,
"stackTrace": [
...
],
"localizedMessage": "No user found with given username...",
"message": "No user found with given username...",
"suppressed": []
}
StackTrace , ...