I'm getting data from Github for my application. The first 2 OAuth steps are ok, but in the third I got the following error: "the server committed a protocol violation. Section=ResponseStatusLine ERROR" This is my code:
protected String WebRequest(string url)
{
url += (String.IsNullOrEmpty(new Uri(url).Query) ? "?" : "&") + "access_token=" + _accessToken;
HttpWebRequest webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
webRequest.Method = "GET";
webRequest.ServicePoint.Expect100Continue = false;
try
{
using (StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream()))
return responseReader.ReadToEnd();
}
catch
{
return String.Empty;
}
}
The program goes in exception after using the StreamReader object, that returns me the error. If I follow these instructions The server committed a protocol violation. Section=ResponseStatusLine ERROR , the error turns into "403 forbidden". When Github used api V2, different from now, there was no problem with this code. So, can't be a .NET limitation but something connected with Github server. Any suggestions?
You need to set UserAgent like this:
webRequest.UserAgent = "YourAppName";
Otherwise it will give The server committed a protocol violation. Section=ResponseStatusLine
error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With