Delete request with body

I am using Retrofit and I want to make a request using the tge delete method. I want to use a specific body, but the delete method does not support this. I created my own class for the delete method as follows:

@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
+4
source share
3 answers

Try this (using Retrofit 2.0):

@FormUrlEncoded
@HTTP(method = "DELETE", path = "/api/resource/etc", hasBody = true)
Call<ApiResponse> deleteSomething(@Field("id") int id);
+18
source
@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);
+2
source

DELETE, . , .

https://github.com/square/retrofit/issues/426

, , , METHOD RUNTIME. - -, ?

+1

All Articles