I\'m trying to make an asynchronous POST and DELETE which is form url encoded using Retrofit in Android 4.4
Here is my client -
@FormUrlEncoded
@POS
The RFC for HTTP is unclear on whether or not the DELETE method is allowed to have a request body or not. Retrofit is raising an error on the side of caution by not having one.
However, you can still include one (assuming the HTTP client supports it) by using a custom HTTP method annotation.
package com.myapp;
@Target(METHOD)
@Retention(RUNTIME)
@RestMethod(value = "DELETE", hasBody = true)
public @interface BODY_DELETE {
String value();
}
Now specify your interface method using the custom annotation that you defined.
@FormUrlEncoded
@BODY_DELETE(INetwork.API_BASE_PREFIX + "/memberships.json")
void leave(@Field("id") String id, Callback> cb);