我正在使用Retrofit,我想用tge delete方法发出请求.我想使用特定的主体,但删除方法不支持.我为delete方法创建了我的自定义类,如下所示:
@Target(METHOD)
@Retention(RUNTIME)
@RestMethod( hasBody = true,value = "DELETE")
public @interface CustomDelete {
String value();
}
Run Code Online (Sandbox Code Playgroud)
但是当我使用它时,我有这个错误:
10-31 16:24:09.459: I/System.out(21090): retrofit.RetrofitError: DELETE does not support writing
Run Code Online (Sandbox Code Playgroud)
rad*_*122 22
试试这个(使用Retrofit 2.0):
@FormUrlEncoded
@HTTP(method = "DELETE", path = "/api/resource/etc", hasBody = true)
Call<ApiResponse> deleteSomething(@Field("id") int id);
Run Code Online (Sandbox Code Playgroud)
小智 1
我也遇到了删除问题,但这是一个更基本的问题,并找到了这个讨论。在我看来,它可能会回答你的问题。
https://github.com/square/retrofit/issues/426
我的问题是,每当我定义接口时,它都会在方法和运行时上给我一个语法错误。我需要在某个地方添加一些东西才能使用它吗?