Android Retrofit 2, differences between addInterceptor & addNetworkInterceptor for editing responses
<p>I've been trying to implement an interceptor <strong>( OkHttp 3.2 &amp; Retrofit 2 )</strong> for editing the JSON response before is returned as response. The server we request data returns different data dependes on success or error and that makes difficult to map the objects. </p>

<p>I was trying to do it by adding the interceptor to Retrofit as a NetworkInterceptor, however the string returned had no format. </p>

<pre><code>@Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();

        Response response = chain.proceed(request);
        try {

            final String responseString = new String(response.body().bytes() ); 

            LOGD("OkHttp-NET-Interceptor", "Response: " + responseString);

            String  newResponseString = editResponse( responseString );

            LOGD("OkHttp-NET-Interceptor", "Response edited: " + newResponseString);
            return  response.newBuilder()
                    .body(ResponseBody.create(response.body().contentType(), newResponseString))
                    .build();

        }catch (Exception ex){
            return response;
        }
    }
</code></pre>

<p><strong>responseString</strong> had a string without any understandable format. </p>

<p>After changing to the normal interceptor, the string had format a it was able to convert to JSONObject.</p>

<p>Could tell me someone which are the differences between the <strong>responses</strong>? </p>

<p>why this line <strong>new String(response.body().bytes() );</strong> return different content?</p>