Hello bubble community,
I’m relying on you after HUNDREDS of unsuccessful attempts.
I’d like to be able to post LinkedIn posts directly via the API. But of course, to please the algorithm, it’s always better to add an image.
When I asked around, I saw that it was possible to do this with LinkedIn’s basic API permissions ( Yes, because LinkedIn restricts access to these APIs enormously ).
The API to use in my case is: POST https://api.linkedin.com/v2/ugcPosts
, which allows you to share a text post accompanied by an image.
However, there are a few subtleties!
In order to integrate the image into the post, you must first inform the POST https://api.linkedin.com/v2/assets?action=registerUpload
API that the image has been uploaded, by filling in this body:
Body : " {
“registerUploadRequest”: {
“owner”: “urn:li:person:<YOUR_LINKEDIN_ID>”,
“recipes”: [
“urn:li:digitalmediaRecipe:feedshare-image”
],
“serviceRelationships”: [
{
“identifier”: “urn:li:userGeneratedContent”,
“relationshipType”: “OWNER”
}
]
}
}
Once this has been done, LinkedIn returns a response containing the url where we can download the image for our future post.
This is the url we should use to download the image:
https://api.linkedin.com/mediaUpload/sp/IDENTIFIANT-UNIQUE-FOURNI/uploaded-image/0?LONG_STRING_WITH_PARAMETER
We retrieve this url and this is where my problem occurs, after correctly filling in the headers : media-type-family: STILLIMAGE
Content-Type: image/png or image/jpg
And after trying every possible body form and every possible API data type, the image still appears empty, even though the request seems to be working.
When I try to make the API call to draft the UGCpost on LinkedIn, it’s successful, but once on LinkedIn, I get a loading error with the media every time.
Has anyone encountered this problem before, or does anyone have an idea of how to solve it?
Thank you in advance!
Don’t hesitate to get back to me if it’s not clear!