我正在尝试替换GET GET url中的字符串。查询如下:替换Android中的Retrofit 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'是查询参数,而不是路径参数 – akash93