title: Get Request in C# Returning 401 Not Authorised
body: <p>Currently trying to do a Get request as part of a c# program. The request works fine on Postman as it uses a header for authorization. However I cannot get the code working for the program to use this header correctly in its Get request. I've had a good look around and tried various bits of code I've found but haven't managed to resolve it so any help would be appreciated!</p>
  
  <pre><code>public string Connect()
          {
              using (WebClient wc = new WebClient())
              {
                  string URI = "myURL.com";
                  wc.Headers.Add("Content-Type", "text");
                  wc.Headers[HttpRequestHeader.Authorization] = "Bearer OEMwNjI2ODQtMTc3OC00RkIxLTgyN0YtNzEzRkE5NzY3RTc3";//this is the entry code/key 
                  string HtmlResult = wc.DownloadString(URI);
                  return HtmlResult;
              }
          }
  </code></pre>
  
  <p>Above is one method inside the class.
  Below is another attempt which is an extension method that gets passed the URL:</p>
  
  <pre><code> public static string GetXml(this string destinationUrl)
              {
                  HttpWebRequest request = 
                  (HttpWebRequest)WebRequest.Create(destinationUrl);
                  request.Method = "GET";
                  request.Headers[HttpRequestHeader.Authorization] = "Bearer 
                  OEMwNjI2ODQtMTc3OC00RkIxLTgyN0YtNzEzRkE5NzY3RTc3";
  
                  HttpWebResponse response;
                  response = (HttpWebResponse)request.GetResponse();
                  if (response.StatusCode == HttpStatusCode.OK)
                  {
                      Stream responseStream = response.GetResponseStream();
                      string responseStr = new 
                      StreamReader(responseStream).ReadToEnd();
                      return responseStr;
                  }
                  else
                  {
                      Console.Write(String.Format("{0}({1})", 
                     response.StatusDescription, response.StatusCode));
                  }
                  return null;
              }
  </code></pre>