users@jersey.java.net

Re: [Jersey] RE: Testing resource class + data in request

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Nov 2009 09:27:03 +0100

On Nov 10, 2009, at 1:24 AM, Rob - wrote:

> Interestingly, I changed
>
> MyBean myBean = this.webResource.path("one/
> two").accept(MediaType.APPLICATION_JSON)
> .post(MyBean.class, new GenericEntity<List<ObjOne>>(objList){});
>
> to be
>
> MyBean myBean = this.webResource.path("one/
> two").type(MediaType.APPLICATION_JSON)
> .post(MyBean.class, new GenericEntity<List<ObjOne>>(objList){});
>
> and it worked.
>

Ah, yes that is correct. Sorry i failed to spot that you did not
declare the content type for the request entity.


> So I guess "accept" works on the server whereas "type" work on the
> actual request?
>

Yes. The accept method sets the Accept request header that enables the
the client to inform the server on the media types are acceptable for
content type of a response entity.

Paul.