LinkedIn发送消息

时间:2013-09-24 19:09:43

标签: c# .net linkedin sendmessage

我想从我的连接向LinkedIn用户发送消息。我尝试以下代码:

            string s = @"<?xml version='1.0' encoding='UTF-8'?>
<mailbox-item>
  <recipients>
    <recipient>
      <person path='/people/1234567' />
    </recipient>
  </recipients>
  <subject>Congratulations on Test.</subject>
  <body>Test Here</body>
</mailbox-item>";

            string url = "https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token=XXXXXXXXXXXX";

            HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest;
            webRequest.Timeout = 10000;
            webRequest.ContentType = "text/xml";
            webRequest.Method = "POST";
            using (var writer = new StreamWriter(webRequest.GetRequestStream()))
            {
                writer.Write(s);
            }

            WebResponse response = webRequest.GetResponse();

我收到异常“远程服务器返回错误:(400)错误请求。”在最后一个字符串上。什么是错误的?

0 个答案:

没有答案