问题
I'm trying to run restlet's first application example - android to gae - but the value returned is alway null, showing a warning in Android's LogCat: Unable to find a converter for this representation : [application/json,UTF-8]
The specific code that returns null is this line:
Contact contact = resource.retrieve();
My Assumption that it's a conversion issue. If so, i'm surprised it's just a warning.
Any idea how to go from here?
Some notes:
- I use restlet 2.1.4
- I used curl to test the server side and it works great. Example:
curl -i -X GET http://127.0.0.1:8888/contacts/123
- To test Android against a local server, I use the following ip: 10.0.2.2
回答1:
Yes, found a solution.
I just needed to register a converter - Specifically Jackson converter. Found the solution in the following SO answer: https://stackoverflow.com/a/5205993/435605
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
The registration I did in Android's application class as it's a global registration.
来源:https://stackoverflow.com/questions/19593337/android-to-gae-restlet-example-doesnt-work-on-the-android-side