title: C# Windows Store App HTTPClient with Basic Authentication leads to 401 "Unauthorized"
body: <p>I am trying to send a HTTP GET request to a service secured with BASIC authentication and https. If I use the RESTClient Firefox plugin to do so there is no problem. I am defining the basic-header and sending the GET to the url and I am getting the answer (data in json).</p>
  
  <p>Now I am working on a Windows Store App in C# which is meant to consume the service. I enabled all required capabilities in the manifest and wrote the following method:</p>
  
  <pre><code>private async void HttpRequest()
          {
              string basic = "Basic ...........";
  
              Uri testuri = new Uri(@"https://...Servlet");
  
              HttpClient client = new HttpClient();
  
              client.DefaultRequestHeaders.Add("Authorization", basic);
  
              Task&lt;HttpResponseMessage&gt; response = client.GetAsync(testuri);
              var text = await response;
              var message = text.RequestMessage;
          }
  </code></pre>
  
  <p>I tried out many different possibilites like getting the response-string but everything lead to an 401 Status Code answer from the Server.</p>
  
  <p>I looked at many similar problems and my understanding of the communication is the following: Client request -> Server response with 401 -> Client sends Authorization header -> Server response with 200 (OK)</p>
  
  <p>What I don't understand is why I am getting the 401 "Unauthorized" Status Code although I am sending the Authorization header right at the beginning. It would be interesting if someone knows how this is handled in the RESTClient.</p>
  
  <p>The BASIC header is definetly correct I was comparing it with the one in the RESTClient.</p>
  
  <p>It would be great if someone could help me with this.</p>
  
  <p>Thanks in advance and kind regards,
  Max</p>