title: Using RestTemplate - how to pass List or Array in parameter from client to server
body: <p>I have a <code>List&lt;Integer&gt;</code> which I want to send to server in parameter, is there any way Spring provide support for this?</p>
  
  <p>I have tried using following code, </p>
  
  <pre><code>restTemplate.exchange("http://xxx.xx.xx.xx:8081/api/cart-items?cartItemsId={cartItemsId[]}", 
              HttpMethod.POST, httpEntity, Void.class, ArrayUtils.toPrimitive(cartItemsId.toArray(new Integer[cartItemsId.size()])));
  </code></pre>
  
  <p>But it sends to server something like:</p>
  
  <p><code>http://xxx.xx.xx.xx:8081/api/cart-items?cartItemsId=%5BI@18275d8c</code></p>
  
  <p>And same issue happens if I use:</p>
  
  <pre><code>restTemplate.exchange("http://xxx.xx.xx.xx:8081/api/cart-items?cartItemsId={cartItemsId[]}", 
              HttpMethod.POST, httpEntity, Void.class, cartItemsId);
  </code></pre>
  
  <p><strong>OR</strong></p>
  
  <pre><code>restTemplate.exchange("http://xxx.xx.xx.xx:8081/api/cart-items?cartItemsId={cartItemsId[]}", 
              HttpMethod.POST, httpEntity, Void.class, cartItemsId.toArray(new Integer[cartItemsId.size()]));
  </code></pre>
  
  <p>Is there any way I can send this List or Array to server using parameters?</p>