I am not able to consume the GitHub V3 API with basic authentication (without using Octokit). I know it works with RestSharp plus I want to know why it does not work with HttpClient
and HttpWebRequest
.
I always get the same answer:
"A protocol violation error occurred"
Here is my code:
using (var client = new HttpClient())
{
var response = client.GetAsync("https://api.github.com/emojis").Result;
if (response.IsSuccessStatusCode)
{
var responseContent = response.Content;
string responseString = responseContent.ReadAsStringAsync().Result;
Console.WriteLine(responseString);
}
}