Could Not Write Request: No Suitable Httpmessageconverter Found for Request Type [Org.Json.Jsonobject] and Content Type [Application/Json]

RestClientException: Could not write request: no suitable HttpMessageConverter found for request type

Resolved. Replaced request paramter with objectMapper.writeValueAsString(request). There was a JSON format issue with request value.

Old code

ResponseEntity<XBrainTradeList> result1 =
new HttpEntity(request, headers),

New code

ResponseEntity<String> rest=
new HttpEntity(objectMapper.writeValueAsString(request), headers),

Also I have taken the response in String format.

no suitable HttpMessageConverter found for request type [request.model.RTPRequest] and content type [application/x-java-serialized-object]

When you send your request, you have to explicitly set contentType header alongside with that accept:


To enforce RestTemplate to use the mentioned MappingJackson2HttpMessageConverter.

Or you can configure HttpRequestExecutingMessageHandler only use this MappingJackson2HttpMessageConverter.

org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type

Spring is not able to parse your request payload (LinkedMultiValueMap) to JSON. Please make sure that you use a converter that can do this. So your request is not sent to the target system.

Please read this for more information:

HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found

The error message says no suitable HttpMessageConverter found for request type, so just add MappingJackson2HttpMessageConverter with MediaType to RestTemplate

MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); 
coverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON);
restTemplate.getMessageConverters().add(0, converter)

no suitable HttpMessageConverter found for response type

From a Spring point of view, none of the HttpMessageConverter instances registered with the RestTemplate can convert text/html content to a ProductList object. The method of interest is HttpMessageConverter#canRead(Class, MediaType). The implementation for all of the above returns false, including Jaxb2RootElementHttpMessageConverter.

Since no HttpMessageConverter can read your HTTP response, processing fails with an exception.

If you can control the server response, modify it to set the Content-type to application/xml, text/xml, or something matching application/*+xml.

If you don't control the server response, you'll need to write and register your own HttpMessageConverter (which can extend the Spring classes, see AbstractXmlHttpMessageConverter and its sub classes) that can read and convert text/html.

java android spring: no suitable HttpMessageConverter found for request type

This fixed my problem

RestTemplate restTemplate = new RestTemplate();
HeartBeat heartBeat = new HeartBeat(appPreferences.getInt("UnitId"), (short) bM.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY), (short) myPhoneStateListener.getSignalStrength(), mSignalType);
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAccept(Arrays.asList(new MediaType("application", "json", Charset.forName("UTF-8"))));
try {
HttpEntity<HeartBeat> entityHeartBeat = new HttpEntity<>(heartBeat, httpHeaders);
ResponseEntity<String> responseEntity = + "SendHeartBeat",
HttpMethod.POST, entityHeartBeat, String.class);
return responseEntity.getBody();
} catch (Exception e) {
Log.e("SiteConnection", ">>>>>>>>>>>>>>>> " + e.getLocalizedMessage());

java api REST client for POST ERROR: no suitable HttpMessageConverter

I had new MappingJackson2HttpMessageConverter() to restTemplate:

RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
ResponseEntity<Object> response = restTemplate.postForEntity("", request, Object.class);

Related Topics

Leave a reply