title: Jersey, how to POST a list of JSON objects?
body: <p>I am building a RESTful web-service in Java using Jersey 1.11, and have problems implementing a method which consumes a list of JSON-ised entities. The single instance method works fine.</p>
  
  <p>The error I get is:</p>
  
  <pre><code>Status 400 - Bad Request. The request sent by the client was syntactically incorrect.
  </code></pre>
  
  <p>My method signature looks like this:</p>
  
  <pre><code>@POST
  @Path("/some-path/{someParam}")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public String createBatch(List&lt;MyEntity&gt; myEnts, @PathParam("someParam") String someParam)
  {
     ... 
  }
  </code></pre>
  
  <p>The JSON I am sending in the requests is an array of <code>MyEntity</code> JSON objects:</p>
  
  <pre><code>[{"field1" : value1, "field2" : value2}, {"field1" : value3, "field2" : value4}, ...]
  </code></pre>
  
  <p>Similar questions have been asked before and one straight forward suggestion was to change the consumed media type to text and de-serialize the <a href="https://stackoverflow.com/questions/11237102/jax-rsjersey-to-consumes-array-of-json-object-in-post-request">JSON manually</a> but I'd prefer a cleaner solution.</p>
  
  <p>Is the JSON I am sending even valid in this context or do I need a top-level <code>{}</code> i.e a wrapper entity? This would also seem a bit un-natural.</p>
  
  <p>Thank you,</p>
  
  <p>/David</p>