Search code examples
androidretrofityandex-maps

Make Get request with using Retrofit


I want to make Request to Yandex using retrofit

Path to make reuqest is http://geocode-maps.yandex.ru/1.x/?format=json&geocode=latitude%2Clongitude

now I have this:

@GET("/?format=json&geocode={geocode}")
Call<YandexResponse> getGeoCollection(@Path("geocode") String geocode);

when I call it i am getting this exception:

URL query string "format=json&geocode={geocode}" must not have replace block. For dynamic query parameters use @Query.

How to correctly make request?


Solution

  • @GET("/")
    Call<YandexResponse> getGeoCollection(@Query("geocode") String geocode, @Query("format") String format);
    

    Then you should manually put format in function invocation:

    webService.getGeoCollection("address", "json");