8

The LinkedIn Share API states that:

Post must contain comment and/or (content/title and content/submitted-url).

This is a bit confusing, but the consequence is that our app cannot share an image unless it has an associated "article" URL. To a degree, this makes sense, since it seems that the Share API was intended to be used to share two things: 1) simple text status updates, and 2) articles.

This might be enough information to give up, but it appears that the LinkedIn web interface does, indeed, allow an image to be shared directly, without an associated URL.

Using the web interface:

enter image description here

The result:

enter image description here

Clicking on the image displays the image in a popup (lightbox):

enter image description here

So, my question is: The web client, as I have shown, clearly has the ability to share images without associated links/URLs. Is there a way to accomplish the same thing using the LinkedIn API?

Thanks!

3 Answers 3

4

I've come to accept the disappointing fact that this is almost certainly just not possible via the API. Boo.

5
  • Do you know if this has changed?
    – Hugh
    Dec 22, 2015 at 21:38
  • As far as I know, it has not changed, but if you find that it has, please report back here! :)
    – rinogo
    Dec 22, 2015 at 21:39
  • Update: The solution provided in the previous comment didn't work.
    – rinogo
    Jan 15, 2018 at 21:22
  • I think the technical "answer" to this is that we need to use Rich Media Shares from the V2 API. The problem with this is that the V2 API appears to be only partially functional/public - it's as if LI got halfway through releasing it and abandoned it. Every request I make to V2 returns permissions errors. Perhaps we need to join one of LI's partner programs?
    – rinogo
    Jan 15, 2018 at 21:25
  • this has changed, read my answer it works. i just implemented it in my app @rinogo Aug 1, 2022 at 10:23
2

You can provide the URL of the image itself as the submitted-url. This makes the link-preview box link to the image. This might not be ideal, but it works to get the image on the post.

However, LinkedIn has strange behavior with these kinds of messages if there are URLs in the comment itself. If there is one URL in the comment, LinkedIn will remove the URL. If there is more than one URL, LinkedIn will display all URLs in the comment. One of these two behaviors is a bug, I suspect.

Here's an image of what a post looks like when submitted-image-url and submitted-url are the same:

enter image description here

5
  • 1
    Thanks, @DecayConstant! Could you provide a screenshot of what the end result will look like? This will help SO'ers know if this is a good option for them.
    – rinogo
    Jan 30, 2017 at 19:13
  • @rinogo I added an image of the result. Jan 30, 2017 at 19:42
  • Thanks, @DecayConstant! :)
    – rinogo
    Feb 1, 2017 at 18:30
  • This is the approach we use; I wish it would work more like the "native" post made directly on linkedin.com, but at least it's better than nothing! Thanks again.
    – rinogo
    Jan 12, 2018 at 23:22
  • @rinogo, use the answer that i've provided Aug 1, 2022 at 10:22
1

The accepted answer is outdated. The API has evolved a lot over the past 8 years.

I've been facing this issue for a week and I finally figured out the solution. Here is the code for it in Node. But, you can use the Payload in another language.

      const payload = {
        owner: 'YOUR-LINKEDIN-AUTHOR-URN',
        text: {
          text: 'This is a sample post'
        },
        distribution: {
          linkedInDistributionTarget: {}
        },
        content: {
          contentEntities: [
            {
              entityLocation: 'https://enlear.academy/how-to-build-a-scalable-email-service-using-aws-d404b347a7fb',
              thumbnails: [
                { resolvedUrl: 'https://miro.medium.com/max/1400/0*a-5BgPfQ7a2Lwe5z.png' }
              ]
            }
          ],
          title: 'Building a Scalable Email Service',
        },
      };

Construct the body using a payload similar to this (just replace your link with my example) and send a POST request to the URL - https://api.linkedin.com/v2/shares.

Additionally attach the Authorization Header with the Bearer Token and attach a second header LinkedIn-Version with the value 202207

For more information, refer the documentation - https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?view=li-lms-unversioned&tabs=http#share-types

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.