I have a legacy Java SE 7 application that can benefit from making a GET request to a REST service.
I tried a modified version of this code https://stackoverflow.com/a/3533714/1081886 for GET requests in JSON format and it works perfectly for successful requests that return an OK status, but error responses like "Not Found" or "Bad Request" cause an IOException in:
InputStream is = connection.getInputStream();
I can always check the status code before this line and act accordingly, but the REST service gives personalized error responses like:
{"success":false,"data":{"error":"Invalid input parameter. The format should be xyz."}}
Is there any way to access these responses using just Java SE 7?