users@jersey.java.net

Re: [Jersey] Error: Request entity is in a format not supported by the requested resource for the requested method

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 03 Apr 2009 17:09:53 -0400

One issue I can see is that the method is marked with
@Consumes({"application/xml","application/json"}) but the body of the
POST is application/x-www-form-urlencoded. You either need to change
the @Consumes to match the POST media type or change the client to
send the correct format.

Marc.

On Apr 3, 2009, at 4:54 PM, Farrukh Najmi wrote:

> Farrukh Najmi wrote:
>> Farrukh Najmi wrote:
>>> Hi Guys,
>>>
>>> This one is surely something really dumb that I am doing wrong...
>>>
>>> I am just starting to add the create method for my resource. The
>>> create RPC never makes it into my jersey annotated create method.
>>> Instead Tomcat valve code seem to be returning the following error:
>>>
>>> "The server refused this request because the request entity is in
>>> a format not supported by the requested resource for the requested
>>> method"
>>>
>>> I do not see a stacktrace anywhere.
>>>
>>> Here is what my new method looks like:
>>>
>>> @Path("/create")
>>> @POST
>>> @Produces({"application/xml","application/json"})
>>> @Consumes({"application/xml","application/json"})
>>> public Response create(@FormParam("xsiType") String xsiType,
>>> @QueryParam("format") String format,
>>> MultivaluedMap<String, String> formParamsMulti) {
>>> ...
>>> }
>>>
>>> This is my first POST method. Here is what the LoggingFilter
>>> output looks like:
>>
>> I misspoke. I had recently done an update method that the last long
>> thread was about.
>> The new method needs to be a PUT method. Please ignore this post
>> until I dig further.
>> Thanks.
>>
>>>
>>> 2 * In-bound request received
>>> 2 > POST http://localhost:8888/rest/create?format=application/json
>>> 2 > accept-encoding: gzip,deflate
>>> 2 > connection: keep-alive
>>> 2 > accept-charset: UTF-8,*
>>> 2 > pragma: no-cache
>>> 2 > content-type: application/x-www-form-urlencoded; charset=UTF-8
>>> 2 > keep-alive: 300
>>> 2 > content-length: 88
>>> 2 > cache-control: no-cache
>>> 2 > host: localhost:8888
>>> 2 > accept-language: en-us,en;q=0.5
>>> 2 > user-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US;
>>> rv:1.7.12) Gecko/20050920
>>> 2 > accept: text/xml,application/xml,application/xhtml+xml,text/
>>> html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
>>> 2 >
>>>
>>> Any idea what I am doing wrong? Thanks for any help.
>>>
>>
>>
> I changed my new "create" method to use HTTP POST and be otherwise
> as much the same as my working "update" method that was the subject
> of the "Unmarshalling JAXB Object from JSON" thread.
>
> I am still getting the Tomcat error and am stumped because I cannot
> see much difference between the working 'update' method and the not
> working 'create' method.
>
> Any ideas on this error would be greatly appreciated. Thanks.
>
> --
> Regards,
> Farrukh
>
> Web: http://www.wellfleetsoftware.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>