È possibile inviare parametro come HashMap o POJO, i parametri trasmetteremo come oggetto JSON. come:
@POST("user/checkloc")
Call<CheckLocation> checkLocation(@Body Location location);
Ecco posizione è oggetto POJO come:
public class Location {
String lat,lng;
public Location(String lat, String lng) {
this.lat = lat;
this.lng = lng;
}
}
e invierà i parametri come oggetto JSON come:
D/OkHttp﹕ --> POST /api/index.php/user/checkloc HTTP/1.1
D/OkHttp﹕ {"lat":"28.4792293","lng":"77.043042"}
È inoltre possibile inviare parametro come HashMap:
@POST("user/checkloc")
Call<CheckLocation> checkLocation(@Body HashMap<String, String> hashMap);
fonte
2016-01-02 12:22:55
Grazie per il tuo commento. Posso inviare altri parametri insieme a Body. Per esempio url, header insieme a Body. –
checkLocation (@Header ("Autorizzazione") token stringa, posizione di posizione @Body); –