Alex Atsoc
Alex Atsoc

Reputation: 11

How to @mention persons and organizations in LinkedIn posts using the API?

I'm trying to publish posts on LinkedIn using their API. Based on their documentation (section: Mentions and Hashtags using Posts commentary) I need to use the person's (or organization's) URN and set in the commentary field:

{
  "author": "urn:li:organization:123456789",
  "commentary": "Hello @[Devtestco](urn:li:organization:2414183)",
  "visibility": "PUBLIC",
  "distribution": {
      "feedDistribution": "MAIN_FEED",
      "targetEntities": [],
      "thirdPartyDistributionChannels": []
  },
  "lifecycleState": "PUBLISHED",
  "isReshareDisabledByAuthor": false
}

My question is: How/where do I get a person's URN?
Do they have an API I can call and simply copy/paste a person's LinkedIn profile URL to then get their URN to mention them in the post?

So far I can't find in their documentation how to get a person's urn:li:person. Only found how and where to use it, but not how to actually get it.

Upvotes: 1

Views: 1627

Answers (1)

Gtobs
Gtobs

Reputation: 21

You'll need access to the Community Management API. Once you have that you can use the People typeahead to search within your own connections (https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/posts-atmention-search-api?view=li-lms-2024-02&tabs=http)

e.g

https://api.linkedin.com/rest/peopleTypeahead?q=memberConnections&keywords=foo

or alternatively the vanityName lookup which requires the full linkedin url of the profile you want

https://api.linkedin.com/rest/vanityUrl?q=vanityUrlAsOrganization&vanityUrl=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fhello-world%2F&organization={organizationUrn}

Both of these will return the person ID for your app. Unfortunately getting approval isn't such a walk in the park.

Upvotes: 1

Related Questions