Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4806

Couldn't parse share document: error in LinkedIn REST API share

$
0
0

I try to call a share REST API with Hammock library function in my MVC 4 application.

Here is my code:

    public ActionResult SharePost()    {        string content = "";        try        {            var credentials = new OAuthCredentials            {                ConsumerKey = "xxxxxxxxxxxxxx",                ConsumerSecret = "xxxxxxxxxxxxxxxx",                Token = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",                TokenSecret = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",                Verifier = verifier,                Type = OAuthType.AccessToken,                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,                SignatureMethod = OAuthSignatureMethod.HmacSha1,                Version = "1.0"            };            var client = new RestClient { Authority = "http://api.linkedin.com/v1", Credentials = credentials, Method = WebMethod.Post };            var request = new RestRequest { Path = "/people/~/shares" };            StringBuilder sbAppend = new StringBuilder();            sbAppend.AppendLine("<?xml version=1.0 encoding=UTF-8?>");            sbAppend.AppendLine("<share><comment>Check out the LinkedIn Share API!</comment><content><title>LinkedIn Developers Documentation On Using the Share API</title><description>Leverage the Share API to maximize engagement on user-generated content on LinkedIn</description><submitted-url>https://developer.linkedin.com/documents/share-api</submitted-url><submitted-image-url>http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png</submitted-image-url></content><visibility><code>anyone</code></visibility></share>");            client.AddHeader("Content-Type", "text/xml");            byte[] msg = Encoding.Default.GetBytes(sbAppend.ToString());            client.AddPostContent(msg);            RestResponse response = client.Request(request);            content = response.Content;        }        catch (Exception ex)        {            throw ex;        }        return Content(content);    }

But I get a error responce.content

enter image description here

Edit

I use double quotes in my xml header. but always shows the same error.

enter image description here

Is there anything wrong?

I didn't see the post XML values in Fiddler. See this image:

enter image description here


Viewing all articles
Browse latest Browse all 4806

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>