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

后端 未结 4 1547
长发绾君心
长发绾君心 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:31

    In Retrofit 2.0, You can use Call interface for the result of your request as below.

    @DELETE("/api/item/{id}")
    Call deleteItem(@Path("id") int itemId);
    
    ...
    
    Call call = YourServiceInstance.deleteItem(10);
    call.enqueue(new Callback() {
    ...
    });
    

提交回复
热议问题