How to get response body using HttpURLConnection, when code other than 2xx is returned?

If the response code isn’t 200 or 2xx, use getErrorStream() instead of getInputStream().

Leave a Comment