3

I have following url http://54.169.227.89:90/DataAccessService.svc/GetProducts/2 which i wanted to use i retrofit get method How to append 2 which is company id which i get from sharepreference during login

Here is ma interface code

public interface ProductsGet {


    String Company_id = OrderApplication.CompanyID_New;


    @GET("/DataAccessService.svc/GetProducts/")
    public void getProducts( Callback<List<ProductsNew>> response);
}
  • @selvin if u want to help then help ppl dont act over smart – Prachi Karapurkar May 09 '16 at 11:13
  • @Selvin - please be constructive - that doesn't help him or the problem at hand. That is rude and who are you to say that programming is not for anyone. Everyone has every right to learn whatever they choose unless you're in North Korea :-) – blackpanther May 09 '16 at 11:22
  • thanks @blackpanther – Prachi Karapurkar May 09 '16 at 11:23
  • @blackpanther *URL MANIPULATION `@GET("group/{id}/users") Call> groupList(@Path("id") int groupId);`* ... this is on http://square.github.io/retrofit/ website ... and i think that lack of reading skill disqualifies from programming, that's it, nothing personal – Selvin May 09 '16 at 11:25
  • @GET("/DataAccessService.svc/GetProducts/{Company_id}") public void getProducts(@Path("COMPANY_ID") String Company_id, Callback> response); – Prachi Karapurkar May 09 '16 at 11:29
  • how to pass it getProducts() fuction – Prachi Karapurkar May 09 '16 at 11:30
  • `service.getProducts("2", callback)` ... i'm not sure but check if parameters are case sensitive or not `@Path("Company_id") <=> @GET("...{Company_id}")` – Selvin May 09 '16 at 11:36

2 Answers2

15

In order to make end point dynamic either you can implementing Endpoint and make use of setUrl() or you can use URL manipulation block which is surrounded by { and }.

     int Company_id = OrderApplication.CompanyID_New;
        
         public interface ProductsGet {
    @GET("/DataAccessService.svc/GetProducts/{COMPANY_ID}") 
public void getProducts(@Path("COMPANY_ID") String Company_id, Callback<List<ProductsNew>> response);
            
            yourreference.getProducts(company_id,new Callback...)
GreenROBO
  • 4,725
  • 4
  • 23
  • 43
Godfather
  • 833
  • 9
  • 14
1
Call<IndentsPojo> call1 = apiInterface.getReport("Basic YWRtaW46MTIzNA==", 1, 10,
                "",
                "", "", "",
                "01-Jan-2018", "06-Mar-2019");

   @GET("Indent/IndentVsIssueReport?")// TODO GET CALL HERE
    Call<IndentsPojo> getReports(@Header("Authorization") String token,
                                     @Query("pageNumber") int pageNumber,
                                     @Query("pageSize") int pageSize,
                                     @Query("quickSearch") String quickSearch,
                                     @Query("indentNo") String indentNo,
                                     @Query("distilleryid") String distilleryid,
                                     @Query("brandcategoryid") String brandcategoryid,
                                     @Query("IssueFromDate") String fromDate,
                                     @Query("IssueToDate") String toDate
                                    );

enter image description here

Keshav Gera
  • 10,807
  • 1
  • 75
  • 53