Reputation: 51
I try to "share" an image+text on LinkedIn using the v2 API. The problem is that this sometimes so that the share does not exist, but there is no error message when uploading.
If calling ugsPosts before the asset referenced is in status AVAILABLE, the call will return 201 Created with an id urn, but no share is created.
We are uploading an image via https://api.linkedin.com/v2/assets?action=registerUpload and then using the link it provides to actually post the image.
If we then try to post a share via https://api.linkedin.com/v2/ugcPosts immediately, it will return 201 Created status with an id tag: "urn:li:share:", which does not exist. If manually going to the profile of the user there is no share posted, and if trying to construct a link like https://www.linkedin.com/feed/update/urn:li:share: it points to nothing.
The only solution we have come up with is to poll https://api.linkedin.com/v2/assets/ until the status is AVAILABLE before calling ugcPosts. However this does not scale very well since the limit for the number of calls to check the status is the same as the number calls to create an image. Is it a bug that the ugcPosts returns 201 Created when it failed to create the post? Is there an official way to create a link to the created share, we want to show a button to the user "view share" when the post is completed?
We currently have to poll for the image asset to becomes "AVAILABLE" before posting the share.
When we call https://api.linkedin.com/v2/assets?action=registerUpload and then directly https://api.linkedin.com/v2/ugcPosts the result is always "201 Created", but the share is not always available.
The issue seem to be that if you call https://api.linkedin.com/v2/ugcPosts, before the status of the image is AVAILABLE (by polling https://api.linkedin.com/v2/assets/) the share will not work.
If ugcPosts is called before all assets are "available" I would have expected it to become available when all assets are.
The second best option would be if you at least got an error in this case.
If you need to poll for assets to become available, this should be mentioned in the documentation (perhaps it is, but I cannot find it) and the call for polling should not be included in your daily quota.
Upvotes: 3
Views: 635
Reputation: 51
So the official answer is:
If you upload images (or other assets) using https://api.linkedin.com/v2/assets?action=registerUpload, you need to poll using https://api.linkedin.com/v2/assets/ and wait for them to become 'AVAIALBLE' before you can reference them in a post to https://api.linkedin.com/v2/ugcPosts. Otherwise, the post will say that it is successful, but will not work.
Upvotes: 2