users@jersey.java.net

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

From: Markus Karg <karg_at_quipsy.de>
Date: Tue, 23 Jun 2009 07:48:48 +0200

Paul,

 

it is rather strange. When using CONTENT_TYPE instead of ACCEPT then
POST is working well (thank you for this tip!). So it seems, PUT and
POST *are* handled differently in Jersey 1.0.3, even if you don't
intended it.

 

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