I am calling another api using RestTemplate but it return error Here is the code
@Autowired
private RestTemplate restTemplate;
@Override
public User getUser(String userId) {
User user = userRepository.findById(userId).orElseThrow(() -> new ResourceNotFoundException("User with give id is not found on server !! " + userId));
//fetch rating for the above user from the RATING SERVICE
String url = "http://localhost:8083/ratings/users/ab2573f5-1b25-41b3-b353-4eb40f995dd5";
Array forObject = restTemplate.getForObject(url, Array.class);
//httpMessageConverter.canRead()
logger.info("{}", forObject);
return user;
}
Exception is -
.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class java.lang.reflect.Array] and content type [application/json]
at .springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:133) ~[spring-web-6.2.1.jar:6.2.1]
at .springframework.web.client.RestTemplate.doExecute(RestTemplate.java:903) ~[spring-web-6.2.1.jar:6.2.1]
enter image description here
enter image description here
enter image description here