title: Get GitHub Rest API User info C# code
body: <p><a href="https://api.github.com/users/[UserName]" rel="nofollow noreferrer">https://api.github.com/users/[UserName]</a> can be accessed via browser. I get a Json result. But I want to retrieve the same information programmatically.</p>
  
  <p>I'm using the below code, which is not working as expected. Please advice.</p>
  
  <pre><code>var credentials = 
  string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", 
  githubToken);
  credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials));
  client.DefaultRequestHeaders.Authorization = new 
  AuthenticationHeaderValue("Basic", credentials);
  var contents = 
  client.GetStreamAsync("https://api.github.com/users/[userName]").Result;
  </code></pre>
  
  <p>As a result of the above code, I'm getting "Aggregate Exception".</p>
  
  <p>How to achieve the requirement using c# code??? Please help</p>
  
  <p>Note: Not expecting a solution with Octokit. Need proper c# code.</p>