• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps HttpPost problems...

Im posting to a webhandler using the HttpPost, although for some reason the way I am doing it, I am not getting the correct response. Is there A way I can view the actual POST it is making? or the query string url?

Code:
 public void postData() {
        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://0.0.0.0/Android/Login.ashx");

        try {
            EditText username = (EditText)findViewById(R.id.username);
            EditText password = (EditText)findViewById(R.id.password);
            
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("un", username.getText().toString()));
            nameValuePairs.add(new BasicNameValuePair("pw", password.getText().toString()));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            
            HttpParams params = new BasicHttpParams();
            params.setParameter("un", username.getText().toString());
            params.setParameter("un", password.getText().toString());
            httppost.setParams(params);
            
            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
            
            String text = ResponseHandler.getResponseBody(response);
            //long length = response.getEntity().getContentLength();


            
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        	e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
        	e.printStackTrace();
        }
    }

I tested the web handler url with http://0.0.0.0/Android/Login.ashx?un=blah&pw=blah and it displayed correctly so I know there is no problem there. Any help would be greatly appreciated.
 
I found the problem was actually with the way I was handling this on the web handler. I wasnt able to figure out how to get the post data on the web handler side, so I did a GET with the parameters as query strings instead and it worked fine
 
Back
Top Bottom