问题
I have a web service link which I want to hit with different customerId in the form of
http://apidev.myserver.com.au:8980/TestService/rest/TestService/jobs/bycustid/customerId
how do I append the value of customerId?
this is my base URL :
http://apidev.myserver.com.au:8980/TestService/rest/TestService/
this is what my interface for calls look like :
interface CustomerJobs {
@GET("jobs/bycustid/11726")
Call<CustomerJobsPojo> getCustomerJobs();
}
回答1:
As the doc says :
interface CustomerJobs {
@GET("jobs/bycustid/{id}")
Call<CustomerJobsPojo> getCustomerJobs(@Path("id") int id);
}
回答2:
Try @Path
annotation
interface CustomerJobs {
@GET("jobs/bycustid/{id}")
Call<CustomerJobsPojo> getCustomerJobs(@Path("id") String id);
}
回答3:
You can embed like
@GET("jobs/bycustid/{custId}")
Call<CustomerJobsPojo> groupList(@Path("custId") int custId);
回答4:
Yes you can use dynamic urls
interface CustomerJobs {
@GET("jobs/bycustid/{customerid}")
Call<CustomerJobsPojo> getCustomerJobs(@Path("id") int customerid);
}
Refer this
来源:https://stackoverflow.com/questions/42689463/get-api-with-retrofit