title: How to add parameters to all HttpClient request methods?
body: <p>I am writing some Java code that uses Apache <code>HttpClient</code> version <code>4.2.2</code> to hit a RESTful 3rd party API. This API has methods that utilize HTTP <code>GET</code>, <code>POST</code>, <code>PUT</code> and <code>DELETE</code>. It's important to note that I'm using a 4.x.x version and not 3.x.x, because the API changed a lot from 3 to 4. All relevant examples I've found have been for a 3.x.x version.</p>
  
  <p>All API calls require you provide the <code>api_key</code> as a <strong>parameter</strong> (regardles of which method you are using). This means that regardles of whether I'm making a GET, POST or otherwise, I need to provide this <code>api_key</code> in order for the call to authenticate server-side.</p>
  
  <pre><code>// Have to figure out a way to get this into my HttpClient call,
  // regardless of whether I'm using: HttpGet, HttpPost, HttpPut
  // or HttpDelete...
  String api_key = "blah-whatever-my-unique-api-key";
  </code></pre>
  
  <p>So I'm trying to figure out how to provide <code>HttpClient</code> with the <code>api_key</code> regardless of my request method (which in turn depends on which RESTful API method I'm trying to hit). It looks like <code>HttpGet</code> doesn't even <em>support</em> the notion of parameters, and <code>HttpPost</code> uses something called <code>HttpParams</code>; but again these <code>HttpParams</code> only seem to exist in 3.x.x version of <code>HttpClient</code>.</p>
  
  <p>So I ask: <strong>What is the proper, v4.2.2 way to attach/add my <code>api_key</code> String to all four</strong>:</p>
  
  <ul>
  <li><code>HttpGet</code></li>
  <li><code>HttpPost</code></li>
  <li><code>HttpPut</code></li>
  <li><code>HttpDelete</code></li>
  </ul>
  
  <p>Thanks in advance.</p>