users@jersey.java.net

[Jersey] Posting with _at_FormParam

From: António Mota <amsmota_at_gmail.com>
Date: Mon, 5 Dec 2011 17:30:05 +0000

Hi again.

I'm trying to POST using Jersey Client but I'm allways getting this:

"A servlet POST request, to the URI
http://localhost:8080/app/rest/image/14961, contains form parameters
in the request body but the request body has been consumed by the
servlet or a servlet filter accessing the request parameters. Only
resource methods using @FormParam will work as expected. Resource
methods consuming the request body by other means will not work as
expected."


My method is defined as

        @POST
        @Path("image/{imageId}")
        public void saveImageAnnotations(@PathParam("imageId") Long imageId,
@FormParam("images") Image[] images);

My invocations is

resource.path("image").path("14961").post(images});

and in "images" I tried several options, like a Form, a MultivalueMap,
a HashMap, a Images[] (I found out later that the first 2 are for
String values only) and serialized both in XML and JSON.


Note that this works OK with the Apache HttpClient based client and
XML representations, and with Jersey on the server.

Any pointer on what I'm doing wrong?


Cheers.