HTTPS Post form Android
<p>So I've searched far and wide for this, used all versions of basically the same code that's floating around for this purpose.</p>

<p>I really don't know what's wrong here and I can't find the reason. Anyway here's my code.</p>

<p>From what I understand, if phoneNumber and PIN are correct...I should be returned the "My Account" page but this isn't the case, it just returns the same page again.</p>

<p>Any help will be greatly appreciated!</p>

<pre><code>private void PostIt() {
    // TODO Auto-generated method stub
    // Create a new HttpClient and Post Header
  String phoneNumber = "1234567890";
  String PIN = "1234";
  HttpParams params = new BasicHttpParams();
  params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

  HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost("https://care.windmobile.ca/signin.aspx?ReturnUrl=%2fMy_Account%2fDefault.aspx");

        try {
            // Add your data
            List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
            nameValuePairs.add(new BasicNameValuePair("__VIEWSTATE", "/wEPDwUKMTk2NDUwMTE2Mg9kFgJmD2QWAgIDD2QWAgIBD2QWBmYPZBYCAgMPFgIeB1Zpc2libGVnFgJmD2QWBAIFDw9kFgIeCm9ua2V5cHJlc3MFS2phdmFzY3JpcHQ6c3VibWl0aXQoZXZlbnQsJ2N0bDAwX21pbmlDYXJ0X1JlZmVyZW5jZU51bWJlckxvYWQxX2J0blN1Ym1pdCcpO2QCBw8PFgIfAGhkZAICD2QWAmYPDxYCHgRUZXh0BQtDYXJ0OiBFbXB0eWRkAgcPZBYCAgEPZBYEZg9kFgQCAg8WAh4Fc3R5bGUFDURpc3BsYXk6bm9uZTtkAg4PDxYCHwJlZGQCAQ9kFgICCQ8PFgIfAGhkZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WBAUqY3RsMDAkbWluaUNhcnQkUmVmZXJlbmNlTnVtYmVyTG9hZDEkYnRuWWVzBRVjdGwwMCRtaW5pQ2FydCRidG5ZZXMFMWN0bDAwJENvbnRlbnRQbGFjZUhvbGRlck1haW4kTG9naW4xJGNoa1JlbWVtYmVyTWUFL2N0bDAwJENvbnRlbnRQbGFjZUhvbGRlck1haW4kTG9naW4xJGltZ0J0bkxvZ2lu23ia8lDQTxfwbvp2fzA6vVPrS8A="));
            nameValuePairs.add(new BasicNameValuePair("__EVENTVALIDATION", "/wEWCwLUx9OsBgKFrrDxDwKAr5ffDwLSrYKxDAKI7JvbCQLnu7OCBQLcrt2bBQLKz4HaAwKm6dz6BQLrwcNyAti18pQOTyeCXHQvJm+6RwcaA+OYx3TE7Ec="));
            nameValuePairs.add(new BasicNameValuePair("ctl00$ContentPlaceHolderMain$Login1$imgBtnLogin.x","53"));
            nameValuePairs.add(new BasicNameValuePair("ctl00$ContentPlaceHolderMain$Login1$imgBtnLogin.y","21"));
            nameValuePairs.add(new BasicNameValuePair("ctl00$ContentPlaceHolderMain$Login1$txtMSISDN", phoneNumber));
            nameValuePairs.add(new BasicNameValuePair("ctl00$ContentPlaceHolderMain$Login1$txtPIN", PIN));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
            Log.d(getPackageName(), "executed http post req");
            HttpEntity resEntity = response.getEntity();
            if (resEntity != null) {    
                Log.i("RESPONSE",EntityUtils.toString(resEntity));
            }
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            Log.e(getPackageName(), "error1 in req");
            e.printStackTrace();
        } catch (IOException e) {
                    // TODO Auto-generated catch block
            Log.e(getPackageName(), "error2 in req");
            e.printStackTrace();
        }
}
</code></pre>
