1

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

制作 reuqest 的路径是http://geocode-maps.yandex.ru/1.x/?format=json&geocode=latitude%2Clongitude

现在我有这个:

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

当我调用它时,我得到了这个异常:

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

如何正确提出请求?

4

1 回答 1

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

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

webService.getGeoCollection("address", "json");
于 2015-11-23T14:52:29.690 回答