Jersey client exception: A message body writer was not found

前端 未结 6 1064
说谎
说谎 2020-12-03 15:55

I am using Jersey client to hit a PHP web service for image uploading functionality. I am getting the following exception:

Caused by: com.sun.jersey.api.clie         


        
6条回答
  •  执笔经年
    2020-12-03 16:27

    Here's my work around:

            WebResource webResource =
                    jerseyClient.resource("www.api.com");
            WebResource.Builder requestBuilder = webResource.getRequestBuilder();
            requestBuilder.header("content-type", "application/json");
            ClientResponse response = requestBuilder
                    .post(ClientResponse.class, mObjectMapper.writeValueAsString(new RequestObject(longUrl)));
            String text = response.getEntity(String.class);
            ResponseObject outcome = mObjectMapper.readValue(text, ResponseObject.class);
    

    I have used Jackson ObjectMapper to serialize the request payload and likewise deserialized the outcome into a ResponseObject instance using ObjectMapper.

提交回复
热议问题