KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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. The error I get is: Status 400 - Bad Request. The request sent by the client was syntactically incorrect. My method signature looks like this: @POST @Path("/some-path/{someParam}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String createBatch(List<MyEntity> myEnts, @PathParam("someParam") String someParam) { ... } The JSON I am sending in the requests is an array of MyEntity JSON objects: [{"field1" : value1, "field2" : value2}, {"field1" : value3, "field2" : value4}, ...] Similar questions have been asked before and one straight forward suggestion was to change the consumed media type to text and de-serialize the JSON manually but I'd prefer a cleaner solution. Is the JSON I am sending even valid in this context or do I need a top-level {} i.e a wrapper entity? This would also seem a bit un-natural. Thank you, /David
Tags (comma-separated)
Save Edits
Cancel