title: Retrofit + POST method + www-form-urlencoded
body: <p>I have a problem with retrofit. I'm pretty new to this library so any help would mean a lot to me. I'm trying to login from app to server <a href="http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-23/" rel="noreferrer">made based on this tutorial</a> (<a href="http://localhost/task_manager/v1/login" rel="noreferrer">http://localhost/task_manager/v1/login</a>), and get json with info about user in result.</p>
  
  <p>MainActivity.java</p>
  
  <pre class="lang-js prettyprint-override"><code>private void requestData() {
  
      String email = "ch@ro.me";
      String password = "chrome11";
      //retrofit tworzenie polecenia
      RestAdapter adapter = new RestAdapter.Builder()
        .setEndpoint(ENDPOINT)
        .build();
  
      //tworzenie api klasy flowers
      UsersAPI api = adapter.create(UsersAPI.class);
  
  
      api.login(email, password, new Callback &lt; User &gt; () {@
        Override
        public void failure(final RetrofitError error) {
          android.util.Log.i("example", "Error, body: " + error.getBody().toString());
  
        }@
        Override
        public void success(User user, Response response) {
          // Do something with the User object returned
          //Log.d("hello", response.toString());
        }
      });
  </code></pre>
  
  
  
  <p>UsersApi.java</p>
  
  <pre class="lang-js prettyprint-override"><code>public interface UsersAPI {
  
    //    @Headers({
    //        "content-type:application/x-www-form-urlencoded"
    //    })
    @FormUrlEncoded
    @POST("/login")
    public void login(@Field("email") String email, @Field("password") String password,
      Callback &lt; User &gt; callback);
  }
  </code></pre>
  
  
  
  <p>User.java</p>
  
  <pre class="lang-js prettyprint-override"><code>public class User {
  
    private String error;
    private String name;
    private String email;
    private String apiKey;
    private String createdAt;
  
    public String getError() {
      return error;
    }
    public void setError(String error) {
      this.error = error;
    }
    public String getName() {
      return name;
    }
    public void setName(String name) {
      this.name = name;
    }
    public String getEmail() {
      return email;
    }
    public void setEmail(String email) {
      this.email = email;
    }
    public String getApiKey() {
      return apiKey;
    }
    public void setApiKey(String apiKey) {
      this.apiKey = apiKey;
    }
    public String getCreatedAt() {
      return createdAt;
    }
    public void setCreatedAt(String createdAt) {
      this.createdAt = createdAt;
    }
  
  
  }
  </code></pre>
  
  
  
  <pre><code>04-20 01:37:46.358: D/gralloc_goldfish(671): Emulator without GPU emulation detected.
  04-20 01:37:55.469: D/dalvikvm(671): GC_CONCURRENT freed 200K, 3% free 10978K/11271K, paused 26ms+15ms, total 87ms
  04-20 01:38:20.518: D/AndroidRuntime(671): Shutting down VM
  04-20 01:38:20.518: W/dalvikvm(671): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
  04-20 01:38:20.540: E/AndroidRuntime(671): FATAL EXCEPTION: main
  04-20 01:38:20.540: E/AndroidRuntime(671): java.lang.NullPointerException
  04-20 01:38:20.540: E/AndroidRuntime(671):  at retrofit.RetrofitError.getBody(RetrofitError.java:80)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at com.hanselandpetal.catalog.MainActivity$1.failure(MainActivity.java:87)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at android.os.Handler.handleCallback(Handler.java:615)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at android.os.Handler.dispatchMessage(Handler.java:92)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at android.os.Looper.loop(Looper.java:137)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at android.app.ActivityThread.main(ActivityThread.java:4745)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at java.lang.reflect.Method.invokeNative(Native Method)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at java.lang.reflect.Method.invoke(Method.java:511)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  04-20 01:38:20.540: E/AndroidRuntime(671):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>