Я звоню в другой API, используя Resttemplate, но он возвращает ошибку
Вот код < /p>
@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/ab2 ... b40f995dd5";
Array forObject = restTemplate.getForObject(url, Array.class);
//httpMessageConverter.canRead()
logger.info("{}", forObject);
return user;
}
< /code>
Exception is -
org.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 org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:133) ~[spring-web-6.2.1.jar:6.2.1]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:903) ~[spring-web-6.2.1.jar:6.2.1]
< /code>
enter image description here
enter image description here
enter image description here
Подробнее здесь: https://stackoverflow.com/questions/793 ... ang-reflec
Нет подходящего httpmessageconverter для типа ответа [класс java.lang.reflect.array] и тип контента [Application/json] ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение