1

I'm trying to send a new Share on a Linkedin Person. This is my client code:

                RestClient client = new RestClient()
                {
                    Authority = "http://api.linkedin.com/v1",
                    Credentials = this.AccessCredentials(connectionData.ApplicationKey, connectionData.ApplicationSecret, connectionData.AccessToken, connectionData.AccessSecret),
                    Method = WebMethod.Post,
                    Encoding = Encoding.UTF8,

                };

                RestRequest request = new RestRequest()
                {
                    Path = "people/~/shares",
                    Encoding = Encoding.UTF8,
                };

                Share share = new Share(socialMessage.Text, socialMessage.Name, socialMessage.Description, VisibilityCode.Anyone);
                share.Content.SubmittedImageUrl = socialMessage.PictureLink;
                share.Content.SubmittedUrl = socialMessage.Link;

                String content = Utilities.SerializeToXml<Share>(share);

                client.AddPostContent(System.Text.Encoding.UTF8.GetBytes(content));
                client.AddHeader("Content-Type", "text/xml");

                request.AddPostContent(System.Text.Encoding.UTF8.GetBytes(content));
                request.AddHeader("Content-Type", "text/xml");

                RestResponse response = client.Request(request);

I always obtain this error message after the call "Couldn't parse share document: error: Unexpected end of file after null".

Does anyone can tell me how to use Hammock library to send a POST to LinkedIn?

Thanks & Regards

Massimo Zerbini
  • 3,125
  • 22
  • 22

2 Answers2

1

Also there is possible solution here: https://github.com/danielcrenna/hammock/issues/4

Pj_pavel
  • 387
  • 3
  • 16
1

I'm not sure how to use the hammock library, but you can debug API calls for LinkedIn (or any other web service) using the tips at http://developer.linkedin.com/documents/debugging-api-calls

This will show you how to install an HTTP sniffer and watch the traffic to see what's happening. Once you've done that, if you're still having issues post them and it'll be possible to debug what's going wrong.

Kirsten Jones
  • 2,681
  • 1
  • 17
  • 20
  • thanks for the tip, I am currently using another library, the LinkedIn Toolkit, without problems. I do not think that the error is due to the LinkedIn API. I'll try to do some debugging on Hammock. – Massimo Zerbini Jan 25 '12 at 08:29
  • @Kristen Jones I have a question for you: in what case the LinkedIn API, in particular 'people/~/shares', send the error message "Unexpected end of file after null" ? – Massimo Zerbini Jan 25 '12 at 08:32
  • Usually this means that either the content-type isn't getting sent correctly or the POST body itself is empty. – Kirsten Jones Jan 25 '12 at 17:12