title: Get 401 unauthorized web exception when consuming rest json api in c#
body: <p>i have bin trying to consume a rest json api with a get request but i always 401 unauthorized exception. According to the owners of the web service they are using http basic authentication. I have tried the credentials by logging in through chrome so they are working fine.</p>
  
  <pre><code>var synCClient = new WebClient();
  synCClient.Credentials = new NetworkCredential("user", "password");
  var content = synCClient.DownloadString(url);
  </code></pre>
  
  <p>I have also tried this solution which i found in kowalczyks blog</p>
  
  <pre><code>string authInfo = userName + ":" + passWord;
  authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
  req.Headers["Authorization"] = "Basic" + authInfo;
  </code></pre>
  
  <p>Any thoughts</p>