美文网首页
Retrofit @Delete with body,Non-b

Retrofit @Delete with body,Non-b

作者: C_zx | 来源:发表于2016-09-28 18:48 被阅读1366次

    使用retrofit进行delete请求时,发现其并不支持向服务器传body,会报这个异常java.lang.IllegalArgumentException:Non-body HTTP method cannot contain @Body ,之前我的delete请求是这么写的
    @DELETE("/my/remove") Call<Void> remove (@Body HashMap<String,String> content);
    结果就出现了Non-body HTTP method cannot contain @Body这错误,然后去github在retrofit Issues 链接 去找了下答案, 发现需要自定义注解,如需向服务器传body可以这么写
    @HTTP(method = "DELETE",path = "/my/remove",hasBody = true) Call<Void> remove (@Body HashMap<String,String> content);

    相关文章

      网友评论

          本文标题:Retrofit @Delete with body,Non-b

          本文链接:https://www.haomeiwen.com/subject/idahyttx.html