users@jersey.java.net

[Jersey] Re: Setting default content types for request

From: Noah White <emailnbw_at_gmail.com>
Date: Fri, 22 Jun 2012 14:47:14 -0400

If you want to treat all Requests as JSON without actually doing any verification you could omit the @Consumes annotation from your root and sub-resources. This would match all requests regardless of their content-type - and I think lack thereof. Since you are talking about globally overriding the content-type in a filter then any drawbacks to this approach would probably be acceptable to you.

Sent from my iPhone

On Jun 22, 2012, at 12:43 PM, Todd Nine <tnine_at_apigee.com> wrote:

> Hi All,
> I've done some work on this and I am experiencing some issues. It looks like I need to modify both the "accept" header and the "Content-Type" headers. However when I do so via a ContainerRequestFilter implementation, I ALWAYS receive a 400 error when processing the request. I've gisted my test cases (which don't pass yet) and the filter and the logs.
>
> https://gist.github.com/4ff589df2ac25da1df9b
>
> Our primary use case is people using curl or wget. By default we want our content type and accept to be application/json, since this is the only format we support in our services.
>
> Is this possible to do with Jersey without causing an error? We're using version 1.11.
>
> Thanks!
> Todd
>
> --
> Todd Nine
>
> On Tuesday, June 19, 2012 at 12:16 PM, Todd Nine wrote:
>
>> Hi all,
>> We're using Jersey in conjunction with the Spring framework. We've configured the following options for our spring servlet. You can view the source here.
>>
>>
>> https://github.com/usergrid/stack/blob/master/rest/src/main/webapp/WEB-INF/web.xml#L80
>>
>>
>>
>> We primarily deal with json data as our main Content-Type. Is it possible to configure the Spring Servlet to set the content type to json if no content type is present in the request header?
>>
>> Thanks,
>>
>> Todd
>>
>