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