public Request(String baseUrl, boolean isPost, Map<String, String> requestParameterMap) throws Exception {
        // construct request url
        String urlStr = baseUrl;

        // add request parameters to url (for GET)
        if (!isPost && requestParameterMap != null) {
            for (String key: requestParameterMap.keySet()) {
                urlStr += "/" + URLEncoder.encode(key, "UTF-8") + "/" + URLEncoder.encode(requestParameterMap.get(key), "UTF-8");
            }
        }

        // create the request
        this.request = isPost ? new HttpPost(urlStr) : new HttpGet(urlStr);

        // add request parameters to body (for POST)
        if (isPost && requestParameterMap != null) {
            List <NameValuePair> nvps = new ArrayList <NameValuePair>();
            for (String key: requestParameterMap.keySet()) {
                nvps.add(new BasicNameValuePair(key, requestParameterMap.get(key)));
            }
            ((HttpPost) this.request).setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
        }
    }