使用改装提出Get请求



我想使用改装向Yandex提出请求

重复使用的路径是http://geocode-maps.yandex.ru/1.x/?format=json&地理编码=纬度%2经度

现在我有了这个:

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

当我称之为时,我得到了这个例外

URL查询字符串"format=json&geocode={geocode}"不能有替换块。对于动态查询参数,请使用@query。

如何正确提出请求?

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

然后您应该手动将格式放入函数调用中:

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

最新更新