为什么我收到内部服务器错误状态 500? LinkedIn API:组织实体共享统计

问题描述 投票:0回答:1

更新:我认为端点存在问题。当未指定特定的 UGC 帖子时,我会得到返回的组织的生命周期统计数据。一旦我用 URN 指定帖子,我就会收到 500 错误。希望 LinkedIn 的人员能够调查此问题,但在提交支持票时我没有得到任何帮助。他们建议在这里发帖

我引用此处链接的文档:https://learn.microsoft.com/en-us/linkedin/marketing/community-management/organizations/share-statistics?view=li-lms-2024-09&tabs=http#检索特定 UGC 帖子的统计信息

这是我的代码。还包括响应的屏幕截图。有什么想法吗? 版本 = '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)
python-requests linkedin-api
1个回答
0
投票

我认为文档已经过时了。 经过一些测试后,似乎您必须使用 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'

© www.soinside.com 2019 - 2024. All rights reserved.