0
votes

I'm getting a simple json response and wanted to map it as follows to a pojo:

ResponseEntity<JsonEntity> response = new RestTemplate().getForEntity(url, JsonEntity.class);

@JsonIgnoreProperties(ignoreUnknown = true)
public class JsonEntity {
    //@JsonProperty getter + setter...
}

But I'm just getting the following exception. What might be missing?

org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class JsonEntity] and content type [application/octet-stream]

2

2 Answers

0
votes

For the default JSON HttpMessageConverter, you'll need to add either Jackson 1 or Jackson 2 to your classpath.

Otherwise, you can add some other JSON library and write your own HttpMessageConverter which can do the deserialization.

0
votes

It turned out the service did not repond with UTF-8 encoding, but ISO 8859-1, which caused the error as Jackson parser can only handly utf-8.