Android Retrofit's @Path don't work. Why?

I have an app which takes trivia question from api and display. When I use the actual link for take questions it works (https://trivia.willfry.co.uk/api/questions?categories=movies&limit=16 ) . However when I add path for categories, app does not work.

This is work :

@GET("questions?categories=general_knowledge&limit=16")
Call<List<Questions>> general();

However this is not work :

@GET("questions?categories={type}&limit=16")
Call<List<Questions>> getData(@Path("type") String type);

Also when I delete the app from emulator, and install again with path include method, it works just once. Not second time.

Answers 1

  • categories is not a path parameter, it's a query, do this instead

    @GET("questions?limit=16")
    Call<List<Questions>> getData(@Query("categories") String categories);
    

    and about the second problem you mentioned, there's noting in the provided code to find out from


Related Articles