I'm using OAuth2RestTemplate
to query an external api that accept a JSON object.
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
HttpEntity<XX> request = new HttpEntity<>(xX, headers);
ResponseEntity<String> response = oAuth2RestTemplate.postForEntity(url , request, String.class);
And I got this error :
org.springframework.web.client.RestClientException: No HttpMessageConverter for [com.yy.XX] and content type [application/json]
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:956) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE]
I tried to add MappingJackson2HttpMessageConverter
to my oAuth2RestTemplate but I got the same error.