title: Spring Rest Template to send JsonArray
body: <p>I am using spring rest template to send json array as request. Source code to send request is as follow:</p>
  
  <pre><code>JSONArray jsonArray = new JSONArray();
  
  for (Iterator iterator = itemlist.iterator(); iterator.hasNext();) {
  
      Item item = (Item)iterator.next();
  
      JSONObject formDetailsJson = new JSONObject();
  
      formDetailsJson.put("id", item.getItemConfId());
      formDetailsJson.put("name", item.getItems().getItemName());
      formDetailsJson.put("price", item.getPrice());
      formDetailsJson.put("Cost",item.getCost());
  
      jsonArray.put(formDetailsJson);
  }
  
  
  List&lt;MediaType&gt; acceptableMediaTypes = new ArrayList&lt;MediaType&gt;();
  acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
  
  // Prepare header
  HttpHeaders headers = new HttpHeaders();
  headers.setAccept(acceptableMediaTypes);
  // Pass the new person and header
  HttpEntity&lt;JSONArray&gt; entity = new HttpEntity&lt;JSONArray&gt;(jsonArray, headers);
  
  System.out.println("Json Object : "+entity);
  // Send the request as POST
  try {
      ResponseEntity&lt;String&gt; result = restTemplate.exchange("my url", HttpMethod.POST, entity, String.class);
  
  } catch (Exception e) {
      logger.error(e);
  
      return "Connection not avilable please try again";
  }
  </code></pre>
  
  <p>And to accept request:</p>
  
  <pre><code>@RequestMapping(value = "/testStock", method = RequestMethod.POST,headers="Accept=application/xml, application/json")
      public @ResponseBody int testStock(@RequestBody List&lt;ItemList&gt;  jsonArray) {
  
          logger.debug("Received request to connect ms access : "+jsonArray.size());
  
          //int returnSizecount = stockList.getStocklst().size();
  
          return 1;
      }
  </code></pre>
  
  <p>The problem is that it giving me following error:
   Could not write request: no suitable HttpMessageConverter found for request type [org.json.JSONArray].Any suggestion is greatly acceptable.</p>