アンドロイド用のJavaでPOSTリクエストを送信したいと思います。アンドロイド用httpポストリクエスト
私はこのコードを使用し:
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
}
問題は、私が使用している場合ということです:
HttpResponse response = httpclient.execute(httppost);
私は例外を取得し、このWebサービスは確かに働いている、