title: Retrofit2 - response body null on success request
body: <p>I'm having a problem with Retrofit2.</p>
  
  <p>When I make a call to my webservice, even in case of success, the body of my response is null.</p>
  
  <p>I tried to make the same call with RESTClient for Firefox and the body contains the correct answer.</p>
  
  <p>This is my stack trace:</p>
  
  <pre><code>D/Call request: Request{method=POST, url=http://myNeo4jServer.com, tag=null}
  D/Call request header: Authorization: Basic xxxxxx
                         Accept: application/json; charset=UTF-8
  D/Response raw header: Server: nginx
                         Date: Tue, 17 May 2016 10:55:13 GMT
                         Content-Type: application/json
                         Content-Length: 21549
                         Connection: keep-alive
                         Access-Control-Allow-Origin: *
                         OkHttp-Sent-Millis: 1463482513167
                         OkHttp-Received-Millis: 1463482513354
  D/Response raw: retrofit2.OkHttpCall$NoContentResponseBody@e6c7df
  D/Response code: 200
  D/Response body: null
  </code></pre>
  
  <p>As you can see:</p>
  
  <ul>
  <li><p>Content-Length: 21549 (I think that counts also the characters in the body)</p></li>
  <li><p>Response code: 200</p></li>
  <li><p>Response body: null</p></li>
  </ul>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>My interface:</p>
  
  <pre><code>public interface PhonebookContactAPI {
      @Headers({
          "Authorization: Basic xxxxxx",
          "Accept: application/json; charset=UTF-8",
          "Content-Type: application/json"
      })
      @POST("/db/data/transaction/commit")
      Call&lt;ResponseBody&gt; get(@Body RequestBody body);
  }
  </code></pre>
  
  <p>My request:</p>
  
  <pre><code>String json = "{\"statements\": [{\"statement\": \"MATCH (n) RETURN n\"}]}";
  
  Retrofit client = new Retrofit.Builder()
          .baseUrl(Globals.BASE_CLIENT_URL)
          .addConverterFactory(GsonConverterFactory.create())
          .build();
  
  PhonebookContactAPI service = client.create(PhonebookContactAPI.class);
  
  RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
  
  Call&lt;ResponseBody&gt; call = service.get(body);
  call.enqueue(new Callback&lt;ResponseBody&gt;() {
      @Override
      public void onResponse(Call&lt;ResponseBody&gt; call, Response&lt;ResponseBody&gt; response) {
  
          Log.d("Call request", call.request().toString());
          Log.d("Call request header", call.request().headers().toString());
  
          Log.d("Response raw header", response.headers().toString());
          Log.d("Response raw", String.valueOf(response.raw().body()));
          Log.d("Response code", String.valueOf(response.code()));
  
          if(response.isSuccessful()) {
              Log.d("Response body", new Gson().toJson(response.body()));
          }
  
          else  {
              Log.d("Response errorBody", String.valueOf(response.errorBody()));
          }
  
      }
  
      @Override
      public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) {
          Log.d("onFailure", t.toString());
      }
  });
  </code></pre>