1

I'm trying to form a request

private final RestTemplate httpClient;
ResponseEntity<DataEntity<User>> response =
    httpClient.exchange(Url,
    HttpMethod.POST, 
    httpEntity,
    User.class);

And I get an error

Required type:ResponseEntity<DataEntity<User>>
Provided:ResponseEntity<User>

What do I need to specify in this parameter?

DataEntity - это класс обертка
public class DataEntity<T>{
    private T data;
}

What should I specify instead User.class ?

alex
  • 324
  • 1
  • 8
  • 28
  • You have mentioned ` User.class` as responseType . Please change this line `ResponseEntity> response` to this `ResponseEntity response`. check this link for your reference: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html – Ajit Soman Dec 28 '21 at 11:50
  • I need the ResponseEntity> response to be in the response. That 's what I need to replace 'User.class `? – alex Dec 28 '21 at 12:36
  • 2
    Please check this answer : https://stackoverflow.com/questions/8108887/generics-with-spring-resttemplate – Ajit Soman Dec 28 '21 at 12:46

0 Answers0