0

Will HTTP post request cause 500 internal server ERROR?. hmmm if so below is my code and why am i constantly getting 500 Internal server error? what am i missing in the code?.

               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");
                    }

thanks,

Anitha
  • 253
  • 4
  • 16
  • Does a stacktrace exists? – Reporter Mar 05 '15 at 12:49
  • http://stackoverflow.com/questions/14065236/500-internal-server-error-with-post-requests could you please look at this before saying further – Anitha Mar 05 '15 at 12:51
  • It is a server side error. –  Mar 05 '15 at 12:51
  • thanks @Goutam but http://stackoverflow.com/questions/14065236/500-internal-server-error-with-post-requests in this link they say its possible to rectify and has 2 upvotes – Anitha Mar 05 '15 at 12:57
  • I know that is a server side error. But sometimes the browser received a stacktrace from server and show it to the user. By the way it depends from the webapplication what was wrong. – Reporter Mar 05 '15 at 12:58
  • I am getting the response object. But my response.getStatusLine() keeps showing 500/ Internal server error for only POST requests. Note : GET requests are working fine. (this is from the link i sent which clearly states the issue is with only POST requests) and someone has given solution to it so if you know exactly its only server error and nothing to do with android code then please kindly say it and that will help me and other viewers allot rather..... – Anitha Mar 05 '15 at 13:04

1 Answers1

0

for me sometimes because of problem on server side I have to send params as header try the same thing like

 HttpPost httppost = new HttpPost((GetAllNewsURL+"?pageNo=0&newsPerPage=0"));

or only pass one param as header hopefully it works

Omid Aminiva
  • 667
  • 5
  • 14