我在一个正在建设的网站上使用Linkedin Rest Api,通常效果很好,唯一的问题是我无法向我的连接发送消息。
({'status': '400',
'content-length': '302',
'transfer-encoding': 'chunked',
'vary': '*',
'server': 'Apache-Coyote/1.1',
'-content-encoding': 'gzip',
'date': 'Wed, 28 Mar 2012 22:52:35 GMT',
'x-li-request-id': 'QU0G42N6TV',
'nncoection': 'close',
'x-li-format': 'xml',
'content-type': 'text/xml;charset=UTF-8'},
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
n<error>n <status>400</status>
<timestamp>1332975155652</timestamp>
<request-id>QU0G42N6TV</request-id>
<error-code>0</error-code>
<message>Couldn't parse mailbox-item document: error: Unexpected end of file after null</message>n</error>n'
这就是我如何调用api的:
client.request(url,'POST','text/xml',param)
其中:
url = 'http://api.linkedin.com/v1/people/~/mailbox'
param:
<?xml version='1.0' encoding='UTF-8'?><mailbox-item>
<recipients>
<recipient>
<person path='/people/TquMAMeCCD' />
</recipient>
</recipients>
<subject>Congratulations on your new position.</subject>
<body>Youre certainly the best person for the job!</body> </mailbox-item>
谢谢!
我的问题终于出现在标题上了,我没有设置正确的内容类型。这就解决了问题。