gpt4 book ai didi

android - 如何使用参数在改造 2 中调用 DELETE 方法

转载 作者:行者123 更新时间:2023-11-29 18:27:44 25 4
gpt4 key购买 nike

我正在使用 retrofit2 调用 delete api,它在 postman 中正常工作,但在应用程序中出现如下错误

Response{protocol=http/1.0, code=405, message=METHOD NOT ALLOWED, url=http://192.168...

这是我的基本网址

public static final String BASE_URL = "http://192.168.1.127:3222/";

@DELETE("student/{firstname}/{lastname}")
Call<ResponseBody> deleteStudent(@Path("firstname") String firstname, @Path("lastname") String lastname);

Java 文件我这样调用它

Call<ResponseBody> call = interfaces.deleteStudent(FirstName,LastName);```

Postman screenshot here

最佳答案

已更新感谢您的引用@GovindPrajapati我必须做一些小改动,添加 @Field,它对我有用。

@FormUrlEncoded
@HTTP(method = "DELETE", path = "student",hasBody = true)
Call<ResponseBody> deleteStudent(@Field("firstname") String firstname, @Field("lastname") String lastname);

关于android - 如何使用参数在改造 2 中调用 DELETE 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57967927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com