title: Send array in JSON POST request with HTTParty
body: <p>I'm trying to work with a 3rd party API that requires an array to be sent within a POST request body. I've already gotten the hang of sending JSON; I've read you just need to set some headers and call <code>to_json</code> on the POST body. However, I'm not sure how to embed an array within that POST body. I've tried the following:</p>
  
  <pre><code>HTTParty.post(url, 
      :body =&gt; { 
          :things =&gt; [{:id =&gt; 1}, {:id =&gt; 2}, {:id =&gt; 3}],
      }.to_json,
      :headers =&gt; { 
          'Content-Type' =&gt; 'application/json', 
          'Accept' =&gt; 'application/json'
      }
  )
  </code></pre>
  
  <p>but this is giving me a server error, leading me to believe the array isn't being formatted correctly. Could someone please advise on how to send an array within a JSON POST request? Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>The error I get back is the following:</p>
  
  <pre><code>#&lt;HTTParty::Response:0x10 parsed_response=nil, 
  @response=#&lt;Net::HTTPInternalServerError 500 Internal Server Error readbody=true&gt;, 
  @headers={"error_message"=&gt;["Can not deserialize instance of java.lang.Long out of 
  START_OBJECT token  at [Source: org.apache.catalina.connector.CoyoteInputStream@30edd11c; 
  line: 1, column: 15] (through reference chain: REDACTED[\"things\"])"], 
  "error_code"=&gt;["0"], "content-length"=&gt;["0"], 
  "date"=&gt;["Wed, 13 Aug 2014 22:53:49 GMT"], "connection"=&gt;["close"]}&gt; 
  </code></pre>
  
  <p>The JSON should be in the format:</p>
  
  <pre><code>{ "things" : [ {"id": "..."}, {"id: "..."}, ... ] }
  </code></pre>