I want to use @Rest api from android annotations to post application/json data to server. How can I do it? I want something like POST request send json data java HttpUrlConnection but as simple as android annotations.
thanks.
I want to use @Rest api from android annotations to post application/json data to server. How can I do it? I want something like POST request send json data java HttpUrlConnection but as simple as android annotations.
thanks.
You can user Retrofit Type-safe REST client for Android and Java.
Use annotations to describe the HTTP request:
support Object
See here a good tutorial Consuming-APIs-with-Retrofit
Actually i think this is well documented in the AA wiki.
@Rest(rootUrl = "http://company.com/ajax/services", converters = { GsonHttpMessageConverter.class })
public interface MyRestClient {
@Post("/events")
void addEvent(Event event);
}
public class Event {
String description;
// ...
}
You you can use MappingJacksonHttpMessageConverter
instead of GsonHttpMessageConverter
if you are using Jackson instead of GSON.
Disclaimer: i am an AndroidAnnotations developer.