I am trying to configure github with a reboot membership.
If I try to call github api from a browser, for example
https://api.github.com/user?access_token=XXXXXXX
I can see all valid json data, however, if I try from .net
public ActionResult Index() { var url = "https://api.github.com/user?access_token=XXXXXXXX"; ////add additional params //if (additionalParams != null) //{ // foreach (string key in additionalParams) // { // url += string.Format("&{0}={1}", key, additionalParams[key]); // } //} HttpClient client = new HttpClient(); var result = client.GetAsync(url).Result; if (result.IsSuccessStatusCode) { var json = result.Content.ReadAsStringAsync().Result; var profile = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(json); //return GetClaimsFromProfile(profile); } return View(); }
I get an error
The server committed a protocol violation. Section = ResponseStatusLine
What is not HttpClient, how about what I'm trying? Do I need to provide additional information that the browser does for me?
Any help would be appreciated!
source share