Search code examples
androidodataretrofit2

How to make retrofit request for Postman url?


I have following url which works in Postman but I need it convert into retrofit request.

/api/schooldata/Galleries?$orderby=Date desc&$skip=0&$top=10&$filter=Type eq 'Video'

I tried this way

 @GET("/Galleries?$orderby=Date desc")
Call<ResponseBody> getPhotoGallery(@Query("top")int top, @Query("skip")int skip, @Query("Type") String _type);

It displays all the items which should filter instead.


Solution

  • I see a few issues,

    You are using the wrong parameter name for Type -> $filter

    Your parameter names are missing the $

    @GET("/Galleries?$orderby=Date desc")
    Call<ResponseBody> getPhotoGallery(
        @Query("$skip") int skip, 
        @Query("$top") int top, 
        @Query("$filter") String _type
    );
    

    Hope that helps!