为什么我不能将@DELETE
与@Url
参数一起使用
@DELETE
Call<ServerResponse> deleteAbsence(@Path("id") int absenceId , @Url String url);
Url passed ="././deleteAbsence/{id}"
堆栈跟踪
java.lang.IllegalArgumentException: @Path can only be used with relative url on @DELETE (parameter #2)
for method WebApiInterface.deleteAbsence
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752)
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743)
at retrofit2.ServiceMethod$Builder.parameterError(ServiceMethod.java:761)
at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:393)
at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:336)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:204)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
答案 0 :(得分:3)
尝试使用@Query("id").
@DELETE
Call<ServerResponse> deleteAbsence(@Query("id") int absenceId , @Url String url);
答案 1 :(得分:0)
带有@Path
注释的参数会替换@DELETE
注释中提供的路径中的提供值。
如果您的任何方法参数都使用@Path
注释进行注释,则必须在@DELETE
注释中提供相对路径作为参数。
将相对路径设置为@DELETE
注释中的参数,而不是方法。
@DELETE("././deleteAbsence/{id}")
Call <ServerResponse> deleteAbsence(@Path("id") int absenceId);