private JSONObject postEvent(String request_type, JSONObject jsonIn) throws java.net.SocketTimeoutException, MessageTypeException,
            java.net.MalformedURLException, IOException, ParkingException {

        formatUrl(request_type, jsonIn);
        url = Config.url;
        if (request_type.equals("event")) {
            switch (jsonIn.get("message_type").toString()) {
                case "IN":
                case "INOFFLINE":
                    url = url + Config.arrivalOperation;
                    break;
                case "OUT":
                case "OUTOFFLINE":
                    url = url + Config.departureOperation;
                    break;
                default:
                    throw new MessageTypeException("Malformed message type");
            }
        } else if (request_type.equals("au")) {
            url = url + Config.availabilityUpdate;
        }
        System.out.println("URL is: " + url);
        
        URL obj = new URL(url);
        con = (HttpURLConnection) obj.openConnection();
        //add reuqest header
        con.setRequestMethod("POST");
        con.setConnectTimeout(connectTimeout);
        con.setReadTimeout(readTimeout);
        //con.setRequestProperty("Content-Type", "application/json");
        con.setDoOutput(true);
        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes(urlParameters);
        wr.flush();
        wr.close();

        responseCode = con.getResponseCode();

        System.out.println("\nSending 'POST' request to URL : " + url);
        //System.out.println("Post parameters : " + urlParameters);
        System.out.println("Response Code : " + responseCode);
        BufferedReader in;
        if (responseCode == 200) {
            in = new BufferedReader(
                    new InputStreamReader(con.getInputStream()));
        } else {
            in = new BufferedReader(
                    new InputStreamReader(con.getErrorStream()));
        }
        String inputLine;
        StringBuilder response = new StringBuilder();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();


        JSONObject jsonResponse = JSONObject.fromObject(response.toString());
        if (jsonResponse.getInt("response_code") != 1) {
            throw new ParkingException(jsonResponse.getString("response_message"));
        }
        return jsonResponse;
    }