I tried making posts on LinkedIn using the Share on LinkedIn API. While posts made with only text involved showed up on LinkedIn as expected, the problem occurs when I try to make a post with image and text in it.
Now, the response to this request suggests that the post was made successfully. Notifications and Analytics on LinkedIn suggest that the post was made. However, the post is not there on my profile, activity or feed, and when I asked others to check their LinkedIn for any posts from me, they couldn't find these posts either.
For reference, I am making the requests on a Colab notebook, and the image was registered and uploaded on LinkedIn successfully before I made the request for the post.
Here is the code for the request.
url4_image_post = "https://api.linkedin.com/v2/ugcPosts"
data_image_post = {
"author": author_urn,
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": text
},
"shareMediaCategory": "IMAGE", # Change from NONE to IMAGE
"media": [
{
"status": "READY",
"description": {
"text": "Work in progress"
},
"media": upload_urn # Include the image asset URN here
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
r4_image_post = requests.post(url4_image_post, headers=headers, json=data_image_post)
# Print the response to see if the post was successful
print(r4_image_post.status_code)
print(r4_image_post.content)
The status code for the request was 201, and the content for the response gives the URN for the post.
feedDistributionyou want? learn.microsoft.com/en-us/linkedin/compliance/integrations/… - "feedDistribution: Specifies the type of feed distribution. Does not distribute to feed when missing."feedDistributionparameter is not available with the Share on LinkedIn API.distributionand links to the section I referred to, so I guess you'd have to nest them -feedDistributionis one of the possible sub-properties ofdistribution?"distribution": { "feedDistribution": "..." }feedDistributioninsidedistribution.