Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing ID in GET request URL through Model class in Retrofit

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

like image 726
jeetdeveloper Avatar asked Nov 01 '18 07:11

jeetdeveloper


2 Answers

Just do it:

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

And then call:

retrofit.deleteRecords("5bd9a270c6a31620e0b7b3d8");
like image 73
punchman Avatar answered Oct 08 '22 16:10

punchman


Try this definition

@GET("course/delete/{id}")
Call<List<Course>> deleteRecords(@Path("id") String id));
like image 21
Mikhail Olshanski Avatar answered Oct 08 '22 16:10

Mikhail Olshanski