title: Retrofit 2 - string error body is empty
body: <p>Server returns <code>JSON</code> object in case of success and simple <code>String</code> for error case. </p>
  
  <p>There are no problems with parsing <code>JSON</code> into object. The problem rises when I want to parse error since the <code>response.errorBody().string()</code> is empty. </p>
  
  <p>When I send the same request using <code>Postman</code> the response as follows:
  <a href="https://i.stack.imgur.com/HR1p7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HR1p7.png" alt="enter image description here"></a></p>
  
  <p>And I can't read this error... Anyone faced such problem? </p>
  
  <hr>
  
  <p>Code code</p>
  
  <p><code>gradle</code>:</p>
  
  <pre><code>compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
  compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
  compile 'com.squareup.okhttp:okhttp:2.6.0'
  </code></pre>
  
  <p><code>RestClient.java</code>:</p>
  
  <pre><code>private static GitApiInterface gitApiInterface;
  ...
  public static GitApiInterface getClient() {
      if (gitApiInterface == null) {
  
          OkHttpClient okClient = new OkHttpClient();
          okClient.interceptors().add(new Interceptor() {
              @Override
              public Response intercept(Chain chain) throws IOException {
                  Response response = chain.proceed(chain.request());
                  return response;
              }
          });
  
  
          Retrofit client = new Retrofit.Builder()
                  .baseUrl(URL_BASE)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
          gitApiInterface = client.create(GitApiInterface.class);
      }
      return gitApiInterface;
  }
  </code></pre>
  
  <p><code>ApiInterface.java</code>:</p>
  
  <pre><code>public interface ApiInterface {
  
  @POST("/register/user/{email}/")
          Call&lt;User&gt; postRegisterUser(@Path(value = "email", encoded = true) String email,
                                        @Query("firstname") String firstName,
                                        @Query("lastname") String lastName,
                                        @Query("country") String country,
                                        @Query("phone") String phone,
                                        @Query("deviceid") String deviceId);
  ...
  </code></pre>
  
  <p><code>ServerRequests.java</code>:</p>
  
  <pre><code> public void registerUser(@NonNull String email,
                           @NonNull String firstName,
                           @NonNull String lastName,
                           @NonNull String country,
                           @NonNull String phone,
                           @NonNull String deviceId,
                           @NonNull final RegisterUserCallback callback) {
      showProgressBar();
  
      RestClient.GitApiInterface service = RestClient.getClient();
      Call&lt;User&gt; call = service.postRegisterUser(email, firstName, lastName, country,  phone, deviceId);
      call.enqueue(new Callback&lt;User&gt;() {
          @Override
          public void onResponse(Call&lt;User&gt; call, Response&lt;User&gt; response) {
              hideProgressBar();
  
              User user = response.body(); //this works great
  
              if (response.isSuccess()) {
                  Log.d(TAG, "REGISTER success: " + response.message());
                  callback.onRegisteredUser(user);
  
              } else {
                  try {
                      Log.e(TAG, "REGISTER fail: " + response.errorBody().string()); //empty error body
                      callback.onRegisterFailed(response.errorBody().string());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
  
          @Override
          public void onFailure(Call&lt;User&gt; call, Throwable t) {
              hideProgressBar();
  
              callback.onRegisterFailed("error");
          }
      });
  }
  </code></pre>