Update POST URL with options

I have a specific web service that has the following POST URL:

(host)/pois/category?lat=...&long=...

Where a category can be three things (say, "cat1", "cat2" or "cat3"), and lat and long double with user geolocation.

Because the url is defined as an annotation like

@POST("/pois/")

How can I add or set these parameters in my URL?

+4
source share
1 answer

You must use annotation @Query

for example, for an endpoint:

/pois/category?lat=...&long=..

Your client should look like this:

public interface YourApiClient {
    @POST("/pois/category")
    Response directions(@Query("lat") double lat, @Query("long") double lng,...);
}

or if you want to use a callback, the client should look like this:

public interface YourApiClient {
    @POST("/pois/category")
    void directions(@Query("lat") double lat, @Query("long") double lng,..., Callback<Response> callback);
}
+9
source

All Articles