Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linkedin eventSubscription API is giving a 403 error

Tags:

linkedin-api

I am using

PUT https://api.linkedin.com/v2/eventSubscriptions/(developerApplication:urn:li:developerApplication:{developer application ID},user:urn:li:user:{member ID},entity:urn:li:organization:{organization ID},eventType:ORGANIZATION_SOCIAL_ACTION_NOTIFICATIONS)

Linkedin API with all the parameters intact. Each URN is encoded as urn:li:organization:12345 is encoded to urn%3Ali%3Aorganization%3A12345 but still getting a 403 Response.

like image 964
Swapnil Sudhir Avatar asked Oct 25 '25 08:10

Swapnil Sudhir


1 Answers

So it turns out that there's a lot of missing/incorrect information in the documentation. Since I'm working in go, here's how I finally got the url formatted correctly:

fmt.Sprintf(
    "https://api.linkedin.com/v2/eventSubscriptions/(developerApplication:%s,user:%s,entity:%s,eventType:ORGANIZATION_SOCIAL_ACTION_NOTIFICATIONS)",
    url.QueryEscape(fmt.Sprintf("urn:li:developerApplication:%s", appId)),
    url.QueryEscape(fmt.Sprintf("urn:li:person:%s", userId)),
    url.QueryEscape(fmt.Sprintf("urn:li:organization:%s", organizationID)),
)

The breakdown:

  • The URNs, and only the URNs, need to be urlencoded.
    • Not the surrounding parentheses
    • Not the commas
    • Not the colons preceding the URNs (developerApplication:, user:, and entity:)
  • Your PUT request needs to include the X-Restli-Protocol-Version header and Authorization header
  • If, for some reason, you use the /rest/eventSubscriptions/ url instead of /v2/eventSubscriptions/, you also need to include the LinkedIn-Version header
  • The appId is not your app's client id, but instead the numeric id you see in the app settings url in the linkedin developer portal (i.e. https://www.linkedin.com/developers/apps/<appId>/auth)
  • The URN structure in the docs is wrong: you need to use urn:li:person:<userId>, not urn:li:user:<userId>
like image 148
Swagner Avatar answered Oct 28 '25 04:10

Swagner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!