I have to write a procedure which will accept body in Hashmap format. I have created HttpEntity with Hashmap values & headers.
public <T> void doPOSTRequest(String url, T body, HttpHeaders headers) throws JsonProcessingException {
HttpEntity<T> request = new HttpEntity<T>(body,headers);
System.out.println("Printing Request :" + request);
ResponseEntity<String> response = null;
//Calling POST Method
//response=restTemplate.postForObject(url,request,String.class);
response=restTemplate.exchange(url, HttpMethod.POST,request,String.class);
System.out.println(response);
}
I am facing below exception :
Exception in thread "main" org.springframework.web.client.RestClientException: No HttpMessageConverter for [java.util.HashMap] at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:957) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:733) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:579) at Com.RESTRequest.doPOSTRequest(RESTRequest.java:39) at Com.GenericREST.main(GenericREST.java:30)