Reputation: 5986
I have a particular web service that has the following POST URL:
(host)/pois/category?lat=...&long=...
Where category can be three things (let's say "cat1", "cat2" or "cat3"), and lat and long are doubles with the user geolocation.
Since the URL is defined as an Annotation like
@POST("/pois/")
How can I add or set these parameters to my URL?
Upvotes: 8
Views: 12605
Reputation: 12365
You should use @Query
annotation
for example for endpoint:
/pois/category?lat=...&long=..
Your client should look like example below:
public interface YourApiClient {
@POST("/pois/category")
Response directions(@Query("lat") double lat, @Query("long") double lng,...);
}
or if you want to use callback, client should look like example below:
public interface YourApiClient {
@POST("/pois/category")
void directions(@Query("lat") double lat, @Query("long") double lng,..., Callback<Response> callback);
}
Upvotes: 27