如何发送带有主体的HTTP删除内容? [英] How to send a HTTP-delete with a body in retrofit?

查看:94
本文介绍了如何发送带有主体的HTTP删除内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试创建删除方法时:

When I try to create a delete method:

public interface ImageService {
    @DELETE("api/v1/attachment")
    Call<BaseResponse> delete(@Body DeleteModel deleteModel);
}

我得到的错误基本上可以从stacktrace归结为以下几行:

I get the error which basically boils down to these lines from the stacktrace:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Failure delivering result
java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.
Caused by: java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.

如何将主体添加到删除方法?

How can I add a body to a delete method ?

我在这里搜索过,但发现3个没有答案,并且使用翻新没有任何结果.

I have searched here but found 3 not answers and nothing using retrofit.

推荐答案

更简单的答案.

@HTTP(method = "DELETE", path = "/api/analysis_delete", hasBody = true)
Call<Analysis_Delete_RequestResult_Api10> analysis_delete_api10(@Field("seq") String seq);

这可以解决问题.

这篇关于如何发送带有主体的HTTP删除内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆