3

I'd like to get Response from server using retforit. Here is some code:

public class ApiManager {
private static String API_URL = "http://192.168.0.142:8080";
private static ApiService service;

interface ApiService {

    @GET("/login")
    Call<User> auth(Callback<User> cb);
}

private ApiManager() {
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(API_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build();

    service = retrofit.create(ApiService.class);
}

public void login(String login, String password) {
    service.auth(new Callback<User>() {
                     @Override
                     public void onResponse(retrofit.Response<User> response) {

                     }

                     @Override
                     public void onFailure(Throwable t) {

                     }
                 }

    );

And User class:

public class User {
private String token;

public String getToken() {
    return token;
}

public void setToken(String token) {
    this.token = token;
}

}

Server return JSONObject {"token": "verysecrettoken"} anyway.

When i call login method app was crashed with Exception java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #1)

What's wrong? Where i can find retrofit documentation? What is it Call? Please help

Yuriy Kolbasinskiy
  • 3,791
  • 3
  • 16
  • 33

2 Answers2

1

Call enqueue, you have the wrong syntax. Try with this early doc:

http://inthecheesefactory.com/blog/retrofit-2.0/en

guillaume_fr
  • 491
  • 3
  • 12
0

Same question is asked here: No Retrofit annotation found. (parameter #1)

Retrofit documentation can be found here: http://square.github.io/retrofit/

Community
  • 1
  • 1
lgvalle
  • 3,712
  • 1
  • 19
  • 14
  • This question about old version of Retrofit :( http://square.github.io/retrofit/ at this link only some examples, without good documentation – Yuriy Kolbasinskiy Sep 15 '15 at 10:11