Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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") int itemId);

But I get the error:

java.lang.IllegalArgumentException: ApiItem.deleteItem: Must have either a return type or Callback as last argument.

However, according to the rules of Rest API, I shouldn't receive any response to DELETE request. How should I specify it in the interface?

Thanks.

like image 284
Mark Korzhov Avatar asked Mar 10 '15 17:03

Mark Korzhov


People also ask

How do I use retrofit delete?

Removing data using DELETE method To delete the data from the server, you need to use the HTTP request method DELETE. In the APIService. kt file, add the @DELETE annotation with the path of the URL you want to delete: interface APIService { // ...

How do I delete a request in API?

In RESTful APIs resources are typically deleted using the HTTP DELETE method. The resource that should be deleted is identified by the request URI. DELETE is an idempotent HTTP operation. Sending the same DELETE request multiple times should only alter the server state once.


1 Answers

@FormUrlEncoded
@HTTP(method = "DELETE", path = "manage-feed", hasBody = true)
Call<ResponseBody> deletePost(@Field("post_id") Integer postId, @Field("share_id") Integer sharedMapId);
like image 107
Dishant Kawatra Avatar answered Oct 15 '22 04:10

Dishant Kawatra