Reputation: 370
@GET
Call<List<User>> getMyFriends(@Header(GlobalDeclarationsRetrofit.HEADER_AUTHORIZATION) String lang, @Url String url, "Need to send a json object here");
Any help should be greately appreciated..
Upvotes: 5
Views: 8007
Reputation: 1775
You can send parameter as hashmap or pojo, the parameters will send as JSON object. as:
@POST("user/checkloc")
Call<CheckLocation> checkLocation(@Body Location location);
Here location is pojo object as:
public class Location {
String lat,lng;
public Location(String lat, String lng) {
this.lat = lat;
this.lng = lng;
}
}
and it will send parameters as JSON object as:
D/OkHttp﹕ --> POST /api/index.php/user/checkloc HTTP/1.1
D/OkHttp﹕ {"lat":"28.4792293","lng":"77.043042"}
You can also send parameter as Hashmap:
@POST("user/checkloc")
Call<CheckLocation> checkLocation(@Body HashMap<String, String> hashMap);
Upvotes: 7