Android : HTTPS Post resulting in HTTP 1.1 500 internal server error

on Friday, December 12, 2014


i`m trying to login to a HTTPS webside (https://mobiel.ziggo.nl/Account/LogOn) but i always get a "HTTP 1.1 500 internal server error" I need to pass following elements and i use a MySSLSocketFactory class which (for now) accepts all certificates:



  • __RequestVerificationToken: token

  • ReturnUrl: ""

  • Username: "user"

  • Password: "pass"


I use following code:



public String postRequest() {
String responseString = "";
HttpClient httpClient = HTTPUtils.getNewHttpClient(REST_SERVER_HTTPS_POST_URI.startsWith(HTTPS_STRING));
HttpResponse response = null;
InputStream in;
URI newURI = URI.create(REST_SERVER_HTTPS_POST_URI);
HttpPost postMethod = new HttpPost(newURI);

try {
postMethod.setHeader("Content-Type", "text/html; charset=utf-8");
postMethod.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("__RequestVerificationToken", "IYx2o6-W-RcdhyV4sbcoWzOLXmsUrtWeYF8Tqee"));
nameValuePairs.add(new BasicNameValuePair("ReturnUrl", ""));
nameValuePairs.add(new BasicNameValuePair("Username", "test"));
nameValuePairs.add(new BasicNameValuePair("Password", "pass"));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));

response = httpClient.execute(postMethod);
Log.e("response", response.getStatusLine().toString());
String aaa = response.getStatusLine().toString();
System.out.println("RESPONSE: " + aaa);

in = response.getEntity().getContent();
responseString = convertStreamToString(in);
} catch (Exception e) {}
return responseString;
}


What could be wrong? Thx for helping me with this.


0 comments:

Post a Comment