括号中的 IllegalArgumentException/必须没有替换块

我有以下密码:

    @GET("api.php?company_name={name}")
Call<Model> getRoms_center(@Query("name") String name);

根据官方文档,我必须使用@Query,我正在使用它,但是我得到了以下错误:

java.lang.IllegalArgumentException: URL query string "company_name={name}" must not have replace block. For dynamic query parameters use @Query.
36015 次浏览

You should do it like that instead:

@GET("api.php")
Call<Model> getRoms_center(@Query("company_name") String name);

Example URL is: http://service.com/movies/list?movie_lang=hindi

for that URL you can use this:

@GET("http://service.com/movies/list")
Single<JsonElement> getMovieList(@Query("movie_lang") String userLanguage);

Example Url: https://api.pray.zone/v2/times/today.jsonlatitude=31.3952348&longitude=&elevation=2000&timeformat=1

to pass in retrofit for that URL you can use this:

@GET("today.json")
Call<SalahMainResponse> getSalahTiming(
@Query("latitude") double latitude,
@Query("longitude") double longitude,
@Query("elevation") int elevation,
@Query("timeformat") int timeformat
);