Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4802

Unable to find a MessageBodyReader of content-type application/json and type class java.lang.String

$
0
0

I am using RestEasy client with jackson providers and getting the above error

clientside code is:

ClientRequest request = new ClientRequest(url);request.accept(MediaType.APPLICATION_JSON);ClientResponse<String> response = request.get(String.class);if (response.getStatus() != 200) {  throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus());}BufferedReader br =  new BufferedReader(new InputStreamReader(new ByteArrayInputStream(response.getEntity().getBytes())));

response.getEntity() is throwing ClientResponseFailure exception with the error being

Unable to find a MessageBodyReader of content-type application/json and type class java.lang.String

My server side code is below:

@GET@Path("/{itemId}")@Produces(MediaType.APPLICATION_JSON)public String item(@PathParam("itemId") String itemId) {  //custom code  return gson.toJSON(object);}

Viewing all articles
Browse latest Browse all 4802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>