2
Talk to me, baby?
I’m trying to pass a parameter in the retrofit, but I’m not getting it. I confess that I’m very beginner in Android. I did a little research, but what I tried didn’t work out so far.
How I tested my api method in Postman: http://localhost:8080/api/user/? [email protected]
So far, so quiet.
Userservice interface
public interface UserService {
@GET("user/?userEmail")
Call<User> getUserByEmail(@Query(value = "email", encoded = true) String email);
Call on the Main Activity
public void getUserByEmail(String email) {
Call<User> call = userService.getUserByEmail(email);
call.enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) {
User userResponse = response.body();
Long id = userResponse.getUserId();
String emailU = userResponse.getEmail();
}
}
@Override
public void onFailure(Call<User> call, Throwable t) {
}
});
}
And well, that’s it. Initially I was using @Path on the interface and passing the same string as the url that was in Postman.
The service is waiting
userEmail
oremail
?– nullptr
Dude, I just saw your answers here. In my api, the parameter is userEmail. I think I got it. I’ll try it here and then I’ll give you a feedback
– Wendell M. Silva