|
Hi there,
I am currently having some difficulties to get @Posts with Restlet Android 2.1-RC1 to use my preferred ("application/json") content representation. Let's start with some details: I have the following resource interface: -- 8< -- public interface EventResource { @Post("json") void record(Event event); } -- 8< -- When making a call to the record method... -- 8< -- final ClientResource clientResource = new ClientResource(Constants.API_URL_EVENTS); clientResource.setChallengeResponse(ChallengeScheme.HTTP_BASIC, ...); final EventResource eventResource = clientResource.wrap(EventResource.class); eventResource.record(event); -- 8< -- ...Restlet picks "application/x-java-serialized-object" as the object representation, which my server does not understand. I have registered the Jackson extension with Restlet: -- 8< -- Engine.getInstance().getRegisteredConverters().add(new JacksonConverter()); -- 8< -- If I clear the list of registered converters before registering the JacksonConverter, Restlet picks the right representation (JacksonRepresentation, application/json). Shouldn't this work automagically without clearing the default converters due to the @Post annotation's "json" value? Thanks, Thilo ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2852544 |
|
On Mon, Oct 10, 2011 at 11:05, Thilo-Alexander Ginkel <[hidden email]> wrote:
> I have registered the Jackson extension with Restlet: > > -- 8< -- > Engine.getInstance().getRegisteredConverters().add(new JacksonConverter()); > -- 8< -- Just a brief follow-up question: Is there a way to influence the Jackson configuration through the Restlet extension? Specifically, I would like to set the SerializationConfig.Feature.WRAP_ROOT_VALUE configuration option on the converter. Thanks, Thilo ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2852607 |
|
On Mon, Oct 10, 2011 at 9:48 AM, Thilo-Alexander Ginkel <[hidden email]> wrote:
See these threads:
--tim |
|
In reply to this post by Thilo-Alexander Ginkel
Sorry for resurrecting this old thread, but I was wondering if you found a better solution than:
Engine.getInstance().getRegisteredConverters().clear(); My post(someObj) were working fine - being handled by the @Post("json") method in the interface (using Restlet 2.2 GAE edition on the server, Restlet 2.2 Android on the client). Then for Android reasons I had to change SomeObj to implement Serializable. This seemed to change the media type to application/x-java-serialized-object which caused my post(someObj) to return a 415 error. Clearing the converters fixed the problem, but I was just curious if you found a better solution. Thanks! RB ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952955 |
|
Engine.getInstance().getRegisteredConverters().add(0, new JacksonConverter());
Worked for me - putting the JacksonConverter first seemed to restore the "automagic" :) RB ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952958 |
|
Another way to do it is to replace the built-in converter with my custom converter. See this message: There has been some activity regarding scoring. Here's a recent issue (which points back to an original older issue):
There have also been some bug fixes regarding scoring, but I don't have pointers to those. --tim
On Wed, Apr 25, 2012 at 8:06 PM, Richard Berger <[hidden email]> wrote: Engine.getInstance().getRegisteredConverters().add(0, new JacksonConverter()); |
| Powered by Nabble | Edit this page |
