public void checkAPIResponse(int status,HttpURLConnection connection)
            throws AftershipAPIException,IOException,ParseException,JSONException{

        if (status>201){

            BufferedReader rd;
            StringBuilder sb;
            String message = "";
            String type = "";
            rd  = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
            sb = new StringBuilder();
            String line;
            while ((line = rd.readLine()) != null)
            {
                sb.append(line + '\n');
            }
//            JSONObject response = new JSONObject(sb.toString());
//            JSONObject meta = response.has("meta")?response.getJSONObject("meta"):new JSONObject();
//            JSONObject data = response.has("data")?response.getJSONObject("data"):new JSONObject();
//            message = meta.has("message")?meta.getString("message"):"";
//            type = meta.has("type")?meta.getString("type"):"";
//            StringBuilder newInformation = new StringBuilder();
//            Iterator<?> keys = data.keys();
//            String key;
//            while( keys.hasNext() ) {
//                key = (String) keys.next();
//                newInformation.append(" " + key + " = " + data.getString(key));
//            }

            throw new AftershipAPIException(sb.toString().trim());
        }

    }