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.
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 { // ...
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.
@FormUrlEncoded
@HTTP(method = "DELETE", path = "manage-feed", hasBody = true)
Call<ResponseBody> deletePost(@Field("post_id") Integer postId, @Field("share_id") Integer sharedMapId);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With