Android HttpClient and HTTPS

Posted by user309769 on Stack Overflow See other posts from Stack Overflow or by user309769
Published on 2010-04-08T21:47:54Z Indexed on 2010/04/08 21:53 UTC
Read the original article Hit count: 571

Filed under:
|
|
|
|

Hi all,

I'm new to implementing HTTPS connections in Android. Essentially, I'm trying to connect to a server using the org.apache.http.client.HttpClient. I believe, at some point, I'll need to access the application's keystore in order to authorize my client with a private key. But, for the moment, I'm just trying to connect and see what happens; I keep getting an HTTP/1.1 400 Bad Request error.

I can't seem to make heads or tails of this despite many examples (none of them seem to work for me). My code looks like this (the BODY constant is XmlRPC):

 private void connect() throws IOException, URISyntaxException{

    HttpPost post     = new HttpPost(new URI(PROD_URL));
    HttpClient client = new DefaultHttpClient();

    post.setEntity(new StringEntity(BODY));
    HttpResponse result = client.execute(post);

    Log.d("MainActivity", result.getStatusLine().toString());

}

So, pretty simple. Let me know if anyone out there has any advice. Thanks!

© Stack Overflow or respective owner

Related posts about android

Related posts about httpclient