title: LinkedIn Share API using RestClient
body: <p>I am trying to post a Share to LinkedIn using OAuth v2 - I have got authorisation correctly and have the appropriate access keys.</p>
  
  <p>Posting to: <a href="https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=(access" rel="nofollow noreferrer">https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=(access</a> token)</p>
  
  <p>Share XML:</p>
  
  <pre><code>&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;share&gt; &lt;content&gt; &lt;title&gt;White
  &gt; Cobalt Ltd&lt;/title&gt; &lt;description&gt;Test&lt;/description&gt;
  &gt; &lt;submitted-url&gt;https://www.whitecobalt.com/&lt;/submitted-url&gt; &lt;/content&gt;
  &gt; &lt;visibility&gt; &lt;code&gt;anyone&lt;/code&gt; &lt;/visibility&gt; &lt;/share&gt;
  </code></pre>
  
  <p>Code to Post (C#):</p>
  
  <pre><code>RestClient oRC = new RestClient();
  RestRequest oRequest = new RestRequest(sURL, Method.POST);
  oRequest.AddHeader("Content-Type", "application/xml");
  oRequest.AddHeader("x-li-format", "xml");
  oRequest.RequestFormat = DataFormat.Xml;
  oRequest.AddBody(xml);
  
  RestResponse oResponse = (RestResponse)oRC.Execute(oRequest);
  if ((oResponse.ResponseStatus == ResponseStatus.Completed) &amp;&amp; (oResponse.StatusCode == HttpStatusCode.Accepted))
  {
  ... success
  }
  </code></pre>
  
  <p>When I use the API Console (<a href="https://apigee.com/console/linkedin" rel="nofollow noreferrer">https://apigee.com/console/linkedin</a>) it works perfectly, but when I try to run it through the code (which as far as I can tell is doing exactly the same thing) I get the following error:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;error&gt;
  &lt;status&gt;400&lt;/status&gt;
  &lt;timestamp&gt;1373465292361&lt;/timestamp&gt;
  &lt;request-id&gt;FQEJFQOL6U&lt;/request-id&gt;
  &lt;error-code&gt;0&lt;/error-code&gt;
  &lt;message&gt;Couldn't parse share document: error: The document is not a share@http://api.linkedin.com/v1: document element local name mismatch expected share got String&lt;/message&gt;
  &lt;/error&gt;
  </code></pre>