Just ran into this myself. I need transactional posts of multiple items, so iterating on the client is out of the question. The consensus seems to be that you need to use a separate path from your normal resources:
http://chasenlehara.com/blog/creating-restful-web-services/ (Multi-resources)
RESTful way to create multiple items in one request
I couldn't find much about how to do this with Jersey, though. As it turns out, it's pretty easy. You should already have multi-entity converter and resource classes for GET requests, you just need to specify a path where the server can assume it's going to receive them:
@Path("creatures")
@Stateless
public class CreaturesResource {
...
@POST
@Consumes({"application/xml", "application/json"})
public Response post(CreatureConverter data) {
Creature entity = data.resolveEntity(em);
postCreature(entity);
}
@POST @Path("multi")
@Consumes({"application/xml", "application/json"})
public Response postMulti(CreaturesConverter data) {
Collection<Creature> entities = data.getEntities();
for (Creature c : entities) {
postCreature(c);
}
}
Then instead of posting
<creature />
to
http://.../resources/creatures
You would post
<creatures>
<creature />
<creature />
</creatures>
to
http://.../resources/creatures/multi