I have made a demo in android, and I'm making a http request to an API. I have made an asynctask for making http request. When I make the request to the API, the app crashed and in logcat it says "illegalargumentException" in my request. I am not getting why it is happening.
**reqUrl = "http://dev.api.ean.com/ean-services/rs/hotel/v3/itin?_type=json&cid=55505&minorRev=99&apiKey=gs28w3m7nqd8y4gsa4x5qsfs&locale="
+ Consts.Locale
+ "¤cyCode="
+ Consts.currencyCode
+ "&xml=<HotelItineraryRequest><itineraryId>"
+ itrny
+ "</itineraryId><email>"
+ mail
+ "</email></HotelItineraryRequest>";**
asynctask
class RequestTask extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
try {
response = httpclient.execute(new HttpGet(uri[0]));
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
responseString = out.toString();
out.close();
} else {
// Closes the connection.
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
// TODO Handle problems..
} catch (IOException e) {
// TODO Handle problems..
}
return responseString;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
System.out
.println("::::::::::::::::::MY ITERNARY RESAPONSE::::::::::::::"
+ responseString);
// Do anything with response..
}
}
I receive the illegal argument at this line:
response = httpclient.execute(new HttpGet(uri[0]));