users@jersey.java.net

Re: [Jersey] Accessing POST body ?

From: Srinivas Naresh Bhimisetty <Srinivas.Bhimisetty_at_Sun.COM>
Date: Tue, 25 Nov 2008 10:38:48 +0530

Hi Arun,

   the POSTed data could be accessed in the resource method by
annotating it with the @Consumes annotation.
The method needs to be annotated with @Consumes(mime-type) and should
have a parameter matching the mime-type. Jersey then gets the POSTed
data to this method parameter.

It would be something like this:
----------------------------------------------------------------------------------------
@POST
@Consumes("text/plain")
public String doSomething(String postedData) {....}
-----------------------------------------------------------------------------------------

-Naresh

Arun Gupta wrote:
> POSTing a request using client APIs as:
>
> ClientResponse cr = resource.
> type("text/plain").
> post(ClientResponse.class, "some stuff");
>
> How do I access "some stuff" in a method on my resource ?
>
> -Arun