I am taking the access token from https://developer.linkedin.com/oauth-test-console,i am taking " oauth_token" from header text box.
When I try with the above toke i am getting "The remote server returned an error: (401) Unauthorized." I am using below code.
try
{
string xml = "<share> <comment>Check out the LinkedIn Share API!</comment> <content> <title>LinkedIn Developers Documentation On Using the Share API</title>";
xml += "<description>Leverage the Share API to maximize engagement on user-generated content on LinkedIn</description>";
xml += "<submitted-url>https://developer.linkedin.com/documents/share-api</submitted-url>";
xml += " <submitted-image-url>http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png</submitted-image-url> </content> <visibility>";
xml += " <code>anyone</code> </visibility></share>";
string accessCodeUri = "http://api.linkedin.com/v1/people/~/shares?oauth2_access_token=generated token"; // this is session value which you get on authorization success return by linkedin
WebRequest request = WebRequest.Create(accessCodeUri);
request.Method = "POST";
request.ContentType = "application/xml";
request.ContentLength = xml.Length;
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
requestWriter.Write(xml);
requestWriter.Close();
WebResponse webResponse = request.GetResponse();
//success
}
catch (WebException exc)
{
}
Even i have tried with https://www.linkedin.com/uas/oauth2/authorization?response_type=code &client_id=YOUR_API_KEY &scope=r_basicprofile%20r_emailaddress &state=STATE &redirect_uri=YOUR_REDIRECT_URI from this URL i have taking the "code(query string)" and i have tried.But getting same error