0

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;
   }
}
svguerin3
  • 2,433
  • 3
  • 29
  • 53
  • Why are you making an instance of a class within its constructor? `LoginBaseRequest` seems like a very useless class – OneCricketeer Jul 08 '17 at 03:38
  • Also, I don't know how your API works, but are you trying to implement HTTP auth, or do your requests literally expect username and password (in plain text) to be part of the request? – OneCricketeer Jul 08 '17 at 03:40
  • Show `ServiceAPI` – Jake Wharton Jul 08 '17 at 03:55
  • I have added additional info and simplified the code a bit; still getting the same error. Please let me know if more info is needed. The requests do indeed expect username/pw in plain text as part of the request body. – svguerin3 Jul 08 '17 at 21:49
  • @Kiskae - that was it! I must have missed that post. Thank you! – svguerin3 Jul 09 '17 at 00:12

0 Answers0