public JSONObject request(String method, String url, JSONObject body)
            throws AftershipAPIException,IOException,ParseException,JSONException{
        BufferedReader rd;
        StringBuilder sb;
        OutputStreamWriter wr;

        HttpURLConnection connection;
        URL serverAddress= new URL(new URL(this.apiHost), this.apiVersion + url);

        connection= (HttpURLConnection)serverAddress.openConnection();
        connection.setRequestMethod(method);
        connection.setReadTimeout(10000);
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Content-Type","application/json");
        connection.setRequestProperty("aftership-api-key", keyAPI);

        if(body!=null){ connection.setDoOutput(true);}//if there is information in body, doOutput true, to write

        connection.connect();
        if(body!=null){
            wr = new OutputStreamWriter(connection.getOutputStream());
            wr.write(body.toString());
            wr.flush();
        }

        this.checkAPIResponse(connection.getResponseCode(),connection);
        rd  = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        sb = new StringBuilder();

        String line;
        while ((line = rd.readLine()) != null)
        {
            sb.append(line + '\n');
        }

        JSONObject response;
        response  = new JSONObject(sb.toString());


        return response;
    }