I am using RestTemplate in my Spring application to interact with an API. I am doing a GET request and expecting some JSON in response. The code to do this is as follows:
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(null, requestHeaders);
ResponseEntity responseLogin = restTemplate.exchange(url, HttpMethod.GET, requestEntity, MyResponse.class);
When I run this its breaks on the following line:
ResponseEntity responseLogin = restTemplate.exchange(url, HttpMethod.GET, requestEntity, MyResponse.class);
I get the following exception:
Could not extract response: no suitable HttpMessageConverter found for response type [com.responses.MyResponse] and content type [application/json;charset=utf-8]
I'm new to RestTemplates and interacting with REST API with Java in general, so any help in solving this problem will be highly appreciated.
You need to specify your messageconverter and bind it: