I'm trying to make a Post request using restTemplate,the problem is the API is accepting List<Users>
in the body as POST Request
public class Users {
String id;
String name;
String gender;
}
I've added the elements as
List<Users> userList=new ArrayList<Users>();
userList.add(new Users("1","AA","Male"));
userList.add(new Users("2","BB","Male"));
userList.add(new Users("3","CC","Female"));
AS
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.postForEntity(URL.toString(), HttpMethod.POST, entity, String.class);
Here how should I pass my userList into the request Body?