Passing ID in GET request URL through Model class in Retrofit

Viewed 6712

This is the API URL for deleting a record

GET : localhost:4000/course/delete/5bd9a270c6a31620e0b7b3d8

5bd9a270c6a31620e0b7b3d8 is an ID which is there in server and model class. I want call an API and pass it dynamically to url for deleting the record.

how to write an interface call request

@GET("course/delete/?id?") //how to write
Call<List<Course>> deleteRecords();

Responses will be appreciated

2 Answers

Just do it:

@GET("course/delete/{id}")
Call<List<Course>> deleteRecords(@Path("id") String id);

And then call:

retrofit.deleteRecords("5bd9a270c6a31620e0b7b3d8");

Try this definition

@GET("course/delete/{id}")
Call<List<Course>> deleteRecords(@Path("id") String id));
Related