0
 @GET("images")
 Call<Example> getimages(@Query("where=item_id") int item_id);

当我在 where 后使用等号将编码为 %3D 时,我的服务器不接受。我希望在我的 api 调用中的where之后使用=符号。

我的链接是 images?where=item_id=1

4

2 回答 2

1

试试这个方法:

@GET("images")
Call<Example> getimages(@Query("where") String item_id);

当你调用这个方法时,你必须通过这种方式:

Service service = retrofit.create(Service.class);
Call<Example> call = service.getimages("item_id=1");

如果您可以成功调用您的 Api,则可以使用字符串连接动态传递值。

原因:在传递查询参数时,您只需将查询参数写入@Query("")其中,并将在运行时为其分配值,然后您将调用此方法并将值传递给方法的“item_id”参数getimages

要了解有关改造的更多信息,请参阅此链接:https ://futurestud.io/tutorials/tag/retrofit

于 2017-02-15T06:51:14.287 回答
0

添加编码标志。

@GET("images")
Call<Example> getimages(@Query("where=item_id", encoded = true) String item_id);

并在将 item_id 传递给此方法之前对其进行编码。

于 2017-02-15T06:53:35.740 回答