I have this url on GitHub where I can search users that have "Leo" on their username:
https://api.github.com/search/users?q=leo%20in:login
I've tried mapping it using retrofit2 but I just don't understand how. What I did was:
@GET("/search/users?q={login}%20in:login")
getUsers(@Path("login") String login);
and just in case:
@GET("search/users")
Call<List<User>> getUsers(@Query("login") String login);
I can see these two ways are not right, but I just can't figure it out the right way.
I'm also not sure if there's a better way to search users, but I got this one from here: https://developer.github.com/v3/search/#search-users
EDITED:
I also tried:
@GET("/search/users")
Call<List<User>> getUsers(@QueryMap Map<String, String> login);
And on the layer that calls this method, I do:
@Override
public void searchUsers(String name) {
Map<String, String> loginMap = new HashMap<>();
loginMap.put(name, "in:login");
Call<List<User>> users = GithubAPI.getInstance().getUsers(loginMap);
users.enqueue(new Callback<List<User>>() {
@Override
public void onResponse(Call<List<User>> call, Response<List<User>> response) {
String s = response.toString();
}
@Override
public void onFailure(Call<List<User>> call, Throwable t) {
}
});
}
Still not working :( And by not working I mean that response.body == null :(
@GET("search/users")
Call<UserList> getUserList(@Query("q") String filter);
Try set letter 'q' as key for request