UPDATE: I believe there is an issue with the endpoint. When not specifiying a specific UGC Post, I get lifetime stats for the organization returned just fine. As soon as I specify a post with the URN, i get a 500 error. Would love for someone at LinkedIn to look into this but am not getting any help when submitting support tickets. They suggest posting here
I am referencing the documentation linked here: https://learn.microsoft.com/en-us/linkedin/marketing/community-management/organizations/share-statistics?view=li-lms-2024-09&tabs=http#retrieve-statistics-for-specific-ugc-posts
Here is my code. Screenshot of response also included. Any ideas? I have a feeling it is an issue with how I’m using version ‘202408’.
code
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)
Tpetey28 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1