I am having an error thrown: java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2)
The POST call that I need to make has a body structure of the following:
"auth": {
"email": "<EMAIL>",
"password": "<PASSWORD>"
}
I can't seem to find what I'm doing wrong.. Thoughts?
AppService api = ApiUtils.getService();
api.login(new LoginRequest(emailEditText.getText().toString(), passwordEditText.getText().toString()), new Callback<Response>() {
@Override
public void onResponse(Call<Response> call, Response<Response> response) {
}
@Override
public void onFailure(Call<Response> call, Throwable t) {
}
});
public class ApiUtils {
public static final String BASE_URL = "https://<API-URL>/";
public static AppService getService() {
return RetrofitClient.getClient(BASE_URL).create(AppService.class);
}
}
public interface AppService {
@POST("/<ENDPOINT>")
Call<Void> login(
@Body LoginRequest request,
Callback<Response> callback
);
}
public class LoginRequest {
@Expose
CreateLogin auth;
private class CreateLogin {
@Expose private String email;
@Expose private String password;
}
public LoginRequest(String email, String password) {
auth = new CreateLogin();
auth.email = email;
auth.password = password;
}
}
public class RetrofitClient {
private static Retrofit retrofit = null;
public static Retrofit getClient(String baseUrl) {
if (retrofit==null) {
retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}