我正在尝试向我的 django 网络服务器发出发布请求(通过浏览器访问时行为正确)
我的邮政编码:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://23.23.237.174/save-item");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("user_email", WeShouldActivity.ACCOUNT_NAME));
for (Field f : mData.keySet()) {
nameValuePairs.add(new BasicNameValuePair(f.getName(), mData.get(f)));
}
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Log.v("GETREFERRALSSERVICE", "backing up items");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
Log.v("GETREFERRALSSERVICE", e.getMessage());
} catch (IOException e) {
// TODO Auto-generated catch block
Log.v("GETREFERRALSSERVICE", e.getMessage());
}
我在 apache2/access.log 中的完整错误(error.log 中没有显示任何内容)
174.253.199.12 - - [16/May/2012:03:25:15 +0000] "POST /save-item HTTP/1.1" 500 53055 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
有谁知道这可能是什么/如何解决?
注意:这是一个错误。该请求没有通过我的视图,它在浏览器中使用完全相同的 url。我首先在视图中打印出请求,但 error.log 中没有显示任何内容