title: How to add parameters to HttpURLConnection using POST using NameValuePair
body: <p>I am trying to do <strong>POST</strong> with <code>HttpURLConnection</code>(I need to use it this way, can't use <code>HttpPost</code>) and I'd like to add parameters to that connection such as</p>
  
  <pre><code>post.setEntity(new UrlEncodedFormEntity(nvp));
  </code></pre>
  
  <p>where</p>
  
  <pre><code>nvp = new ArrayList&lt;NameValuePair&gt;();
  </code></pre>
  
  <p>having some data stored in. I can't find a way how to add this <code>ArrayList</code> to my <code>HttpURLConnection</code> which is here:</p>
  
  <pre><code>HttpsURLConnection https = (HttpsURLConnection) url.openConnection();
  https.setHostnameVerifier(DO_NOT_VERIFY);
  http = https;
  http.setRequestMethod("POST");
  http.setDoInput(true);
  http.setDoOutput(true);
  </code></pre>
  
  <p>The reason for that awkward https and http combination is the need for <em>not verifying</em> the certificate. That is not a problem, though, it posts the server well. But I need it to post with arguments. </p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p><strong>Duplicate Disclaimer:</strong></p>
  
  <p>Back in 2012, I had no idea how parameters were inserted into an <strong>HTTP POST</strong> request. I was hanging on to <code>NameValuePair</code> because it was in a tutorial. This question might seem like a duplicate, however, my 2012 self read that <em><a href="https://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily">other</a></em> question and it was <strong>NOT</strong> using <code>NameValuePair</code>. It did not, in fact, solve my problem.</p>