Reputation: 11931
I am using retrofit's library in my android app to retrieve records from my "Sync" table in my database on my server (used Loopback to generate the endpoints). I created a custom endpoint that requires a variable of type long which is a timestamp in unix format such as 1466598649119. The problem is that when I call the endpoint
@GET("Syncs")
Call<List<Sync>> getAllSyncsAfterThisTimeStamp(@Query(("getRecodsAfterTimestamp?timeChanged=")) long timeChanged);
public static final Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.0.2.2:3000/api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
with this value:
Long timeStamp = 1466598625506L;
Log.e(TAG, "Job Service task is running...");
getAllSyncsCall = espcService.getAllSyncsAfterThisTimeStamp(timeStamp);
getAllSyncsCall.enqueue(EspcJobSheculerService.this);
it should return only the records with timestamp after or equal to the provided one but instead I am retrieving all of the records (the total number of records in my table is 3)
I know that my end point works because I am testing it on the Loopback's API explorer and it returns the correct number of records so obviously I am doing something wrong on the device site.
Upvotes: 0
Views: 387
Reputation: 157447
getRecodsAfterTimestamp?timeChanged="
is the problem. getRecodsAfterTimestamp
is not part of the query but of your path. Retrofit takes car of adding =
and ?
@GET("Syncs/getRecodsAfterTimestamp")
Call<List<Sync>> getAllSyncsAfterThisTimeStamp(@Query(("timeChanged")) long timeChanged);
should do it
Upvotes: 2