How to add parameters to HttpURLConnection using POST

Posted by Michal Švácha on Stack Overflow See other posts from Stack Overflow or by Michal Švácha
Published on 2012-03-19T09:45:47Z Indexed on 2012/03/19 10:03 UTC
Read the original article Hit count: 439

Filed under:
|

I am trying to do POST with HttpURLConnection(I need to use it this way, can't use HttpPost) and I'd like to add parameters to that connection such as

post.setEntity(new UrlEncodedFormEntity(nvp));

where

nvp = new ArrayList<NameValuePair>();

having some data stored in. I can't find a way how to add this ArrayList to my HttpURLConnection which is here:

HttpsURLConnection https = (HttpsURLConnection) url.openConnection();
https.setHostnameVerifier(DO_NOT_VERIFY);
http = https;
http.setRequestMethod("POST");
http.setDoInput(true);
http.setDoOutput(true);

the reason for that awkward https and http combination is the need for not verifying the certificate. That is not a problem, though, it posts. But I need it to post with arguments. Any ideas?

Thanks a lot!

© Stack Overflow or respective owner

Related posts about android

Related posts about httpurlconnection