Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call DELETE method in retrofit 2 with params

I am calling delete api using retrofit2 it is working in postman properly but giving error in application as below

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

here is my base url

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);

and java file i'm calling it like

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

Postman screenshot here

like image 922
YuvrajsinhJadeja Avatar asked Oct 17 '25 10:10

YuvrajsinhJadeja


1 Answers

Updated thanks for your referance @GovindPrajapati i have to make little changes add @Field and it is working for me.

@FormUrlEncoded
    @HTTP(method = "DELETE", path = "student",hasBody = true)
    Call<ResponseBody> deleteStudent(@Field("firstname") String firstname, @Field("lastname") String lastname);
like image 190
YuvrajsinhJadeja Avatar answered Oct 20 '25 01:10

YuvrajsinhJadeja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!