Retrofit error URL query string must not have replace block

只愿长相守 提交于 2019-12-03 02:28:35
Jake Wharton

Query params have their own annotation which automatically appends to the URL.

@GET("/users?filters[0][operator]=equals")
UserDto retrieveUsersByFilters(
    @Query("filters[0][field]") String nameFilter,
    @Query("filters[0][value]") String value);

You can read more about @Query on its Javadoc

 URL="/api-mobile_prateek2.php?method=getProductById&pid="


 @GET("/api-mobile_prateek2.php?method=getProductById")
    Call<Product> responseproduct(@Query("pid") String pid);

dont put the pid in the @GET,, Retrofit automatically fix the url, using @Query

Don't put your values directly in the path, but prefer in the method signature. Not completely sure, but try something like this :

@GET("/users?filters[0][operator]=equals")
UserDto retrieveUsersByFilters(@Path("filters[0][field]") String nameFilter, @Path("filters[0][value]") String value);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!