Unable to find a MessageBodyReader of content-type text/html and type interface java.util.List

落爺英雄遲暮 提交于 2019-12-06 15:44:21

I had the same problem. It was caused by the server which did not, as expected, return a content-type: application/json, but it returned:

content-type: text/html; charset=UTF-8

I see two options:

1) contact the provider of the service and ask that application/json be returned

2) read the result of your request as a String and manually convert it to an object. Similar to this:

String jsonData = response.readEntity(String.class);
ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
JsonNode jsonNode= mapper.readValue(jsonData, com.fasterxml.jackson.databind.JsonNode.class);

Now, create a List from the jsonNode data...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!