Reputation: 412
how can annotate retrofit method to pass "&page=1" and "&per_page" parameters in the following link: https://api.github.com/search/repositories?q=tetris&page=1&per_page=10 I want to be able to change these parameters at runtime. I figured out how to annotate query param "tetris", but I couldn't find it for "&page=1" and "&per_page" parameters. Here is my retrofit interface:
String BASE_URL = "https://api.github.com/";
@Headers("User-Agent: useragent")
@GET("search/repositories")
Call<GitHubRepo> searchRepos(@Query("q") String searchParam);
Upvotes: 1
Views: 509
Reputation: 1053
@GET("search/repositories")
Call<GitHubRepo> searchRepos(
@Query("page") Integer page),
@Query("per_page") Integer perPage
)
Upvotes: 2
Reputation: 7918
Those are also query parameters.
The first query parameter in an URL is always added using a '?', and all following query parameters are added using a '&'. This is a standard for URLs, not just in Android, but everywhere.
Retrofit will take care of correctly using '?' and '&' in the right places for you, so simply add all the query parameters you want, just like you added them in your current setup, and it should work.
Upvotes: 4