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

Apps HttpPost problems...

ninjasenses

Newbie
Feb 9, 2010
38
0
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.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones