简体   繁体   中英

C# LinkedIn Rest API 401 Error

I am trying to access a user profile through their url as specified here https://developer.linkedin.com/documents/profile-api# in the format of a GET like this

https://api.linkedin.com/v1/people/url=<public-profile-url> 

I know my oAuth is set up correctly because when I paste the completed oAuth url into a private browser I get valid XML back. My problem is that when I try and access the url via code I get a 401 Unauthorized error. I have tried accessing the valid url in all of the ways below and still get a 401. ( url variable below is a valid oAuth url string)

webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
webRequest.Method = method.ToString();
webRequest.ServicePoint.Expect100Continue = false;
responseData = WebResponseGet(webRequest);

WebClient client = new WebClient();
responseData = client.DownloadString(url);

XmlDocument doc1 = new XmlDocument();
doc1.Load(url);
responseData = doc1.ToString();

Why do I keep getting 401 errors?

Traced the bug back to a .Net HttpWebRequest security limitation. My solution is found here C# HttpWebRequest GET partially encoded url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM