title: Consuming REST Webservice. API Key Authentication
body: <p>I have little problem that I have been trying to solve for some time. I want to connect to a REST web service and I have the API key for that web service that I want to consume. I have tried the service in the Google REST console and it works fine.</p>
  
  <p>But when I try to build a c# .net project for it I dont know how to set the api key for the authentication. I took this code from other site:</p>
  
  <pre><code>string url = "http://Demo.company.com/Data/Values/1029/CarPart/id/"
  HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url);
  GETRequest.Method = "GET";
  
  Console.WriteLine("Sending GET Request");
  HttpWebResponse GETResponse = (HttpWebResponse)GETRequest.GetResponse();
  Stream GETResponseStream = GETResponse.GetResponseStream();
  StreamReader sr = new StreamReader(GETResponseStream);
  
  Console.WriteLine("Response from Server");
  Console.WriteLine(sr.ReadToEnd());
  </code></pre>
  
  <p>How can I authenticate this service with my Api key: asdf1234. I need to add it to my header but how? Can you show me some code example?</p>
  
  <p>Cheers
  Thor</p>