邮件请求android 500内部服务器错误

时间:2015-03-05 12:48:39

标签: android http-post

HTTP post请求会导致500内部服务器错误吗?嗯,如果这样下面是我的代码,为什么我经常得到500内部服务器错误?我在代码中缺少什么?。

               HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost((GetAllNewsURL));

                try {

                    // Add your data
                    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
                            1);

                    nameValuePairs.add(new BasicNameValuePair("pageNo", "0"));
                    nameValuePairs.add(new BasicNameValuePair("newsPerPage",
                            "0"));
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);
                    HttpEntity entity = response.getEntity();
                    stream = entity.getContent();
                    BufferedReader reader = new BufferedReader(
                            new InputStreamReader(stream));
                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }

感谢,

1 个答案:

答案 0 :(得分:0)

对我来说,有时因为服务器端的问题我必须发送params作为标题尝试像

一样的事情
 HttpPost httppost = new HttpPost((GetAllNewsURL+"?pageNo=0&newsPerPage=0"));

或者只传递一个参数作为标题,希望它可以正常工作