Sie können senden Parameter senden, senden die Parameter als JSON-Objekt geschätzt werden sollte. wie:
@POST("user/checkloc")
Call<CheckLocation> checkLocation(@Body Location location);
Hier Lage ist pojo Objekt wie:
public class Location {
String lat,lng;
public Location(String lat, String lng) {
this.lat = lat;
this.lng = lng;
}
}
und es wird Parameter als JSON-Objekt senden, wie:
D/OkHttp﹕ --> POST /api/index.php/user/checkloc HTTP/1.1
D/OkHttp﹕ {"lat":"28.4792293","lng":"77.043042"}
Sie auch Parameter wie HashMap schicken:
@POST("user/checkloc")
Call<CheckLocation> checkLocation(@Body HashMap<String, String> hashMap);
Vielen Dank für Ihren Kommentar. Kann ich andere Parameter zusammen mit Body senden? Zum Beispiel URL, Header zusammen mit Body. –
checkLocation (@Header ("Authorization") Zeichenfolge Token, @Body Location location); –