Search code examples
javarestjersey

How to get full REST request body using Jersey?


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.


Solution

  • 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 {
        ...
    }