I want to send POST request in java for android.
I Use this code :
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("myUrl");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("artist", "Amy Macdonald"));
nameValuePairs.add(new BasicNameValuePair("title", "Don't Tell Me That It's Over"));
nameValuePairs.add(new BasicNameValuePair("album", "Don't Tell Me That It's Over"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
The problem is that when i use :
HttpResponse response = httpclient.execute(httppost);
i get an exception, and this webservice is working for sure,