Skip to content
Advertisement

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.

Advertisement

Answer

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 {
    ...
}
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement