Java 自定义HTTP方法在改装2中不起作用

Java 自定义HTTP方法在改装2中不起作用,java,android,retrofit2,okhttp3,Java,Android,Retrofit2,Okhttp3,您好,我在我的代码中使用了自定义方法,如下所示,但它总是给我 java.lang.IllegalArgumentException:方法AUTH不能有 请求主体 我的代码不起作用,它总是说:custommethodauth,不能有正文 @Headers("Content-Type: application/json") @HTTP(method = "AUTH", path = "login/{deviceId}", hasBody = true) Call<Success> g

您好,我在我的代码中使用了自定义方法,如下所示,但它总是给我

java.lang.IllegalArgumentException:方法AUTH不能有 请求主体

我的代码不起作用,它总是说:
custommethodauth,不能有正文

@Headers("Content-Type: application/json") 
@HTTP(method = "AUTH", path = "login/{deviceId}", hasBody = true) 
Call<Success> getLogin( @Path("deviceId") int deviceId, @Body RequestBody password); 

您能帮助我吗。

我也有同样的问题,在搜索文档后,我发现问题是
改装
版本,请尝试使用版本
2.4.0
或更高版本

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

因此,请删除
@Body RequestBody密码
。您应该执行的请求方法是什么?GET?POST?PUT?我需要将密码作为原始数据传递到正文中:{“password”:“****”}。我还使用了自定义http方法,如中所示:您必须发送请求的uri是什么?它是auth/login/{deviceId}吗?您必须执行什么方法?不,URL是:{deviceId},AUTH是自定义方法名。为什么要编写http方法?读取tldr不使用自定义方法
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'