title: How to pass API_KEY through HttpWebRequest
body: <p>I'm trying to send <code>curl</code> request passing some headers and authentication info.</p>
  
  <p>All information i want to send went successfully but I'm stuck with how to send the api key that should be used instead of the normal username/password manner.</p>
  
  <p>when I use online <code>curl</code> websites to send the <code>curl</code> request, I put <code>:</code> after the api key and then everything works perfectly.</p>
  
  <p>And this is what i want to do in C# using <code>HttpWebRequest</code></p>
  
  <p>This is the code I'm using in order to do that:</p>
  
  <pre><code>string credentials = String.Format("{0}:{1}", "API_KEY", "GivenApiKey: ");
          byte[] bytes = Encoding.ASCII.GetBytes(credentials);
          string base64 = Convert.ToBase64String(bytes);
          string authorization = String.Concat("Basic ", base64);
          var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.website.com/test");
          httpWebRequest.ReadWriteTimeout = 100000; 
          httpWebRequest.ContentType = "application/json";
          httpWebRequest.Accept = "application/json";
          httpWebRequest.Method = "POST";
          httpWebRequest.UserAgent = "GivenUserAgent";
          httpWebRequest.Credentials = new NetworkCredential("Authorization", authorization);
  </code></pre>
  
  <p>please any help?</p>