ninjasenses
Newbie
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?
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.
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.