I have this query string to send a http request via a URI object, but the URI object reformats my query string, including the parameters.
(the %3F and the ? are wrong)
The code:
String queryString = "";
queryString += "/ebl/remote";
queryString += "/" + getToken();
queryString += "/v2/cart/addProduct?";
queryString += "cid=" + getCartID();
if (getItemID() != null) {
queryString += "&pid=" + getItemID();
}
queryString += "&qty=1";
URI uri = null;
try {
uri = new URI("http", null, getDomain(), 80, queryString, "", null);
} catch (Exception e) {}
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(uri);
System.out.println("Add product request: " + httpget.getURI());
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);
} catch (Exception e) {}
Can someone help me fix this please?
path
variable and your query string should go in thequeryString
variable. TheURI
is escaping the query because you are telling it that it's part of the path. – Boris the Spider 22 hours ago