更新:我认为端点存在问题。当未指定特定的 UGC 帖子时,我会得到返回的组织的生命周期统计数据。一旦我用 URN 指定帖子,我就会收到 500 错误。希望 LinkedIn 的人员能够调查此问题,但在提交支持票时我没有得到任何帮助。他们建议在这里发帖
这是我的代码。还包括响应的屏幕截图。有什么想法吗? 版本 = '202408'.
url = "https://api.linkedin.com/rest/organizationalEntityShareStatistics"
params = {
"q": "organizationalEntity",
"organizationalEntity": organization_id,
"ugcPosts": "urn:li:ugcPost:"
}
headers = {
'Authorization': f'Bearer {linkedin_api_accesstoken}',
'Linkedin-Version': version,
'X-Restli-Protocol-Version': '2.0.0'
}
# Make the GET request
response = requests.get(url, headers=headers, params=params)
# Check the response status code and print the response
if response.status_code == 200:
print("Success:", response.json())
else:
print("Error:", response.status_code, response.text)
我认为文档已经过时了。 经过一些测试后,似乎您必须使用 List(urn1,urn2) 作为 ugcPosts 参数值。 urn 值必须编码,但 List 的括号不能编码。
这是一个带有虚拟数据的 cURL 示例:
curl -X GET 'https://api.linkedin.com/rest/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=urn%3Ali%3Aorganization%3A0123456789&ugcPosts=List(urn%3Ali%3AugcPost%3A0987654321)'-H 'X-Restli-Protocol-Version: 2.0.0' -H 'Authorization: Bearer accessToken' -H 'LinkedIn-Version: 202410'