When I post a request through rest template,It throws no suitable HttpMessageConverter

503 Views Asked by At
HttpHeaders reqheaders= new HttpHeaders();
reqheaders.set(HttpHeaders.Accept,MediaType.Application_xml)
reqheaders.set(HttpHeaders.Content_type,MediaType.Application Json)
HttpEntity XML= new HttpEntity (json,reqheaders)
ResponseEntity<Map> xmlfile= restTemplate.exchange(url,HttpMethod.POST,XML, Map.class)

I am getting no suitable HttpMessageConverter found for response type[interface java.util.Map] and content type [application/xml;charset=UTF-8]

1

There are 1 best solutions below

0
On

it looks like no suitable HttpMessageConverter is registered with the RestTemplate can convert xml content to a Map object.

There some HttpMessageConverters which are pre-enabled and can be checked here. You need to make sure that the suitable HttpMessageConverter is on your classpath.