Retrofit 2.0 - How to get response body for 400 Bad Request error? : <p>So when I make a POST API call to my server, I get a 400 Bad Request error with JSON response.</p>

<pre><code>{
    "userMessage": "Blah",
    "internalMessage": "Bad Request blah blah",
    "errorCode": 1
}
</code></pre>

<p>I call it by </p>

<pre><code>Call.enqueue(new Callback&lt;ResponseBody&gt;() {
    @Override
    public void onResponse(Call&lt;ResponseBody&gt; call, Response&lt;ResponseBody&gt; response) {
        //AA
    }

    @Override
    public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) {
        //BB
    }
}
</code></pre>

<p>However the problem is that once I get the response, onFailure() is invoke so that //BB is called. Here, I have no way to access the JSON response.
When I log the api request and response, it doesn't show JSON response at all. And Throwable t is IOException. However, strangely, when I make the same call on Postman, it does return the expected JSON response with 400 error code. </p>

<p>So my question is how can I get the json response when I get 400 Bad Request error? Should I add something to okhttpclient?</p>

<p>Thanks</p>
