How to get full REST request body using Jersey?

Marcus Leon picture Marcus Leon · Nov 12, 2009 · Viewed 142.5k times · Source

How can one get the full HTTP REST request body for a POST request using Jersey?

In our case the data will be XML. Size would vary from 1K to 1MB.

The docs seem to indicate you should use MessageBodyReader but I can't see any examples.

Answer

Marcus Leon picture Marcus Leon · Nov 20, 2009

Turns out you don't have to do much at all.

See below - the parameter x will contain the full HTTP body (which is XML in our case).

@POST
public Response go(String x) throws IOException {
    ...
}