【发布时间】:2017-01-02 15:45:30
【问题描述】:
我正在尝试替换我的 GET 网址中的字符串。查询如下:
@GET("read/something/Books?$filter=(substringof('{filter}',Description)+or+substringof('{filter}',Code)+or+substringof('{filter}',Title)+or+substringof('{filter}',Barcode))")
Call<ApiResponse<Book>> getFilteredBooks(@Path("filter") String filter);
所以我想用动态字符串替换 {filter}。 我收到一个错误:
java.lang.IllegalArgumentException: URL query string "$filter=(substringof('{filter}',Description)+or+substringof('{filter}',Code)+or+substringof('{filter}',Title)+or+substringof('{filter}',Barcode))" must not have replace block. For dynamic query parameters use @Query.
我找不到任何其他可以按预期工作的合适注释。
【问题讨论】:
-
对于初学者来说,错误消息告诉你问题是什么。你需要使用@Query 而不是@Path。
filter是查询参数而不是路径参数