Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete request with body

Tags:

retrofit

I'm using Retrofit and I want to make a request with tge delete method. I want to use a specific body, but the delete method doesn't support that. I created my custom class for delete method like this:

@Target(METHOD) 
@Retention(RUNTIME) 
@RestMethod( hasBody = true,value = "DELETE") 
public @interface CustomDelete {   

String value();      

 } 

But when I use it I have this error:

10-31 16:24:09.459: I/System.out(21090): retrofit.RetrofitError: DELETE does not support writing
like image 794
David Lara Avatar asked Oct 31 '14 23:10

David Lara


2 Answers

Try this (with Retrofit 2.0):

@FormUrlEncoded
@HTTP(method = "DELETE", path = "/api/resource/etc", hasBody = true)
Call<ApiResponse> deleteSomething(@Field("id") int id);
like image 53
radu122 Avatar answered Sep 30 '22 16:09

radu122


@HTTP(method = "DELETE",path="/api/v1/media/{username}/{accesstoken}", hasBody = true)
Call<MyResponse> deleteArchiveMedia(@Path("username") String username, @Path("accesstoken") String token  ,
                                    @Body DeleteMedia deleteMedia);
like image 43
Nison Cheruvathur Avatar answered Sep 30 '22 16:09

Nison Cheruvathur