users@jersey.java.net

Re: [Jersey] POST is not working when body is provided

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 23 Jun 2009 09:28:54 +0200

On Jun 22, 2009, at 7:52 PM, Markus KARG wrote:

> Paul,
>
> thanks for the tip with the logging, I will try it out tomorrow. :-)
>
> No, there are really no other changes but only replaced @PUT by @POST.
>
> The client is a simple HttpUrlConnection.
>

I suspect that HttpUrlConnection may be working differently for PUT/
POST requests.

Paul.


> I will check the log, thanks! :-)
>
> Regards
> Markus
>
> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> Sent: Montag, 22. Juni 2009 16:12
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] POST is not working when body is provided
>
> Hi Markus,
>
> There is nothing specific in Jersey that differentiates between POST
> and PUT apart from the mapping to a method that is annotated with
> @POST or @PUT.
>
> What client are you using? did you make modifications to that other
> than changing PUT to POST?
>
> Can you add logging and see what the client sends?
>
> https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
>
> Paul.
>
> On Jun 22, 2009, at 4:04 PM, Markus Karg wrote:
>
>
> I can do a PUT to my JAX-RS resource, but I want to use a POST. So I
> just replaced @PUT by @POST and kept the rest of the code. Now it
> does not work anymore: If the body is empty, everything works well.
> But if a body is provided (which shall get attached as a child to
> the existing resource, hence the POST instead of the PUT), then it
> says that it "415 Unsupported Media Type".
>
> This is really weird, since PUT works really well, and the media
> type is "application/xml" and the body is a InputStream...!
>
> Can anybody tell me what to do...?
>
> Thanks!
> Markus
>