>  Q&A  >  본문

android - Retrofit API的GET

https://api.heweather.com/x3/weather?cityid=城市ID&key=XXXXXXXXX
这种API 如何用Retrofit 来书写呢

     @GET("x3/weather?cityid={cityid}&key={apikey}")
    Call<WeatherResult> WeatherGet(@Path("cityid") String id,@Path("apikey") String key);
这样写 被提示要使用`@Query("cityid") String id`

Call<WeatherResult> WeatherGet(@Query("cityid") String id,@Path("apikey") String key);


修改完后 又被提示 Path 不能放在 Query后面

那么我想问这样的API 如何写呢

PHP中文网PHP中文网2715일 전466

모든 응답(1)나는 대답할 것이다

  • 阿神

    阿神2017-04-17 17:52:26

    https://futurestud.io/tutoria... 이에 따르면 이렇게 작성해야 합니다

    으아악

    여기서 path을 사용할 수 없는 이유는 api_key이 쿼리 문자열로 사용되므로 query이 계층적 파일 경로를 나타내기 때문입니다. path참조 자료
    https://zh.wikipedia.org/wiki...

    회신하다
    0
  • 취소회신하다