protected InputStream getInputStream(URL requestUrl, Map<String, String> params) throws ApiException {
		OutputStreamWriter wr = null;
		try {
			URLConnection conn = openConnection(requestUrl);
			conn.setDoOutput(true);
			wr = new OutputStreamWriter(conn.getOutputStream());
			StringBuilder data = new StringBuilder();
			for (Entry<String, String> entry : params.entrySet()) {
				if (data.length() > 0) data.append("&"); // to ensure that we don't append an '&' to the end.
				String key = entry.getKey();
				String value = entry.getValue();
				data.append(URLEncoder.encode(key, "UTF8"));
				data.append("=");
				data.append(URLEncoder.encode(value, "UTF8"));
			}
			wr.write(data.toString());
			wr.flush();
			return conn.getInputStream();
		} catch (Exception e) {
			throw new ApiException(e);
		} finally {
			if (wr != null)
				try {
					wr.close();
				} catch (IOException e) {
					LOG.warn("Error closing the stream", e);
				}
		}
	}