Linkedin eventSubscription API is giving a 403 error - linkedin

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.

I think you forget to add this in headers :
X-Restli-Protocol-Version:2.0.0

The application id is actually a numeric field in the url when you visit your application settings, put that value instead of the client id.

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>

Related

Linkedin API V2 query by VanityName with ampersand doesn't work

Working example: https://api.linkedin.com/v2/organizations?q=vanityName&vanityName=apple
Basically this is working for any other company, except if it has a & in the name, for example:
cannot use this vanity name (doesn't seem to be a url encode problem on the client side):
johnson-&-johnson or johnson-%26-johnson
The error is always the same:
serviceCode: 100
status: 403
message: Unpermitted fields present in PARAMETER: Data Processing Exception while processing fields [/-johnson]
This is not a permission problem, its working with any other vanity name.
In the response the uri seems to be messed up: https://api.linkedin.com/v2/organizations?-johnson=&q=vanityName&vanityName=johnson-
It should equal the request which is https://api.linkedin.com/v2/organizations?q=vanityName&vanityName=johnson-%26-johnson.
Also documentation doesn't seem to mention this use case.
Some other examples that work
https://api.linkedin.com/v2/organizations?q=vanityName&vanityName=johnson-controls-middle-east-africa
https://api.linkedin.com/v2/organizations?q=vanityName&vanityName=lowe's-home-improvement

LinkedIn sharing SHARE_URL#HASH URL Param

I am faced with a LinkedIn sharing issue.
This issue probably reproducible from March 1st 2019.
I share some url e.g. https://www.linkedin.com/sharing/share-offsite/?url=SHARE_URL#HASH
Worked before: link in post(href) - SHARE_URL#HASH
Works now: link in post(href) - value of og:url meta tag from SHARE_URL#HASH page
So we lose request parameters in SHARE_URL and #HASH
How we can pass link for LinkedIn post into request?
You need to do URL-encoding with parameters you are feeding to another URL. So, this is what you should want...
https://www.linkedin.com/sharing/share-offsite/?url=SHARE_URL%23HASH
Remember, URL's use things like ? and # to indicate a special argument occurring after this character. So, for instance, example.com/share.php?title=thisistitleright?&..., how would the browser know that the first ? indicates the GET param and the second ? is a part of the title argument? Easy: URL encoding.
In case you want to know more: Official LinkedIn Share Documentation

Getting RefererNotAllowedMapError from GAPI whereas the restriction pattern defined seems to match the referring URL

A.S/ probably for another SE.com site: why "referer" is spelt with only r at Google's?
Anyway, here we go again with another occurrence of RefererNotAllowedMapError.
I couldn't find my answer in the existing Q&As.
Hypothesis:
I have a local website that includes a GMap.
It displays and works
fine provided I remove all restrictions on that key, from the Google
API console.
But the browser will receive a Google Maps JavaScript
API error: RefererNotAllowedMapError whenever I add a referrer
restriction, which seems to match the refering URL.
The referrer, where the map is being called form, is:
https://app.developr.online.local/projects?p=name-asc-0-20-1&a=createProject
Below is my GAPI KEY security configuration:
Below is the corresponding console output:
To be noted:
If I add a trailing asterisk when declaring the referer, validating that entry will clear it anyway. To me it means: "that's ok, we're covering trailing /* already.".
My question: what pattern should I enter as a referrer (2 r's) to have it recognised by GAPI security layer?
I've tried a few things, I didn't get a cigar.
Thank you.

What is the # in this post request for?

I'm using fiddler to observe a redirect request and the request looks like this:
https://example.com/api/dothis#code=123456&name=abcdef
I'm not familiar with what the hashtag (#) is for. Could I get an explanation?
If it is an HTTP POST request to https://example.com/api/dothis#code=123456&name=abcdef, I think it is due to the backend (bad) design: The backend endpoint of /api/dothis will parse the string after # and extract the code and name parameter.
For the hashtag (#) itself, normally it is used to indicate anchor of HTML content, please refer to Fragment Identifier for more information. According to the wikipedia's description, it is unlikely that #code=123456&name=abcdef works as fragment identifier.
# is also used in Single Page Application to navigate between application UIs. But it's not the case, as the HTTP method in this question is POST.

Getting S_412_PRECONDITION_FAILED=Invalid arguments error in Linkedin share api

When try to update status with link in linkedin api i'm getting this error frequently.
Example Link:
http://www.world-grain.com/articles/news_home/World_Grain_News/2016/06/General_Mills_files_patent_on.aspx?ID={30B4213B-4E10-4AF6-9B56-0D5614D7AFD3}&cck=1
If i remove the { and } from the link it get posted. Even in linkedin site itself its not working.
Help me if anyone know the reason.
I was receiving the same error and the reason was that I didn't send values for all the keys in request's body. For example: "content" parameter in linkedin's request body is a dictionary with 4 keys:
title
description
submitted-url
submitted-image-url
I had no image url so I didn't set the key "submitted-image-url" at all. The solution was to set the value to empty string "".
I wonder why linkedin can't parse dictionary if it doesn't have all the keys but that's the way it works.
Hope this helps
You may need to URL encode the braces in your link:
http://www.world-grain.com/articles/news_home/World_Grain_News/2016/06/General_Mills_files_patent_on.aspx?ID%3D%7B30B4213B-4E10-4AF6-9B56-0D5614D7AFD3%7D&cck=1
I ran into the same error when I attempted to pass a URL with spaces. It published successfully after URL encoding the spaces (%20).

Resources