How to perform a DELETE request without return type or Callback? [Retrofit]

后端 未结 4 1606
长发绾君心
长发绾君心 2021-02-20 11:07

I need perform a DELETE request using Retrofit. So, my code snippet of the interface looks like this:

@DELETE(\"/api/item/{id}\")
void deleteItem(@Path(\"id\") i         


        
4条回答
  •  一整个雨季
    2021-02-20 11:36

    You have to add Callback as last argument in request method if you want to have void method. You can useCallback.

    You have to change this:

    @DELETE("/api/item/{id}")
    void deleteItem(@Path("id") int itemId);
    

    to :

    @DELETE("/api/item/{id}")
    void deleteItem(@Path("id") int itemId, Callback callback);
    

    Or you can return just Response

    @DELETE("/api/item/{id}")
    Response deleteItem(@Path("id") int itemId);
    

提交回复
热议问题