I cannot figure out how to pass in a Java List into a Spring RestTemplate call and then use the list in the Controller method
Client code:
public String generateInfoOfIds(List<String> ids, String userName, String password){
RestTemplate restTemplate = new RestTemplate();
String response = null;
String url = "https://someservice.com/getInfoOfIds?";
restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(userName, password));
response = restTemplate.exchange(url+"ids=" + ids, HttpMethod.GET, null, String.class);
return response;
}
Controller code:
@RequestMapping(value = "/getInfoOfIds", method = RequestMethod.GET)
public String getInfoOfIds(@RequestParam("ids") List<String> ids) {
String response = myService.doSomeWork(ids);
return response;
}
The call to he controller itself works but he List is not converting to the @RequestParam ids correctly.
How exactly do you pass a List from a RestTemplate to a Controller in Spring?