Are projections no longer working for /posts in the LinkedIn API 202301
Asked Answered
B

2

6

We are fetching all posts by author in the LinkedIn Rest API. We are using a projection to enrich the author with things like name and logo. Here is the query:

curl "https://api.linkedin.com/rest/posts?author={MY_ORG}&q=author&count=50&projection=(elements(*(*,author~(vanityName,localizedName,logoV2(*,cropped~:playableStreams(*,elements*(identifiers*(identifier))))))))" \
   -H "LinkedIn-Version: 202212" \
   -H "Authorization: .."

This works fine, however if I change to LinkedIn-Version: 202301 I get this response:

{
  "status": 400,
  "code": "ILLEGAL_ARGUMENT",
  "message": "projection parameter is not allowed for this endpoint"
}

Is this documented anywhere? How do I get the author's details instead?

Barnabas answered 26/1, 2023 at 16:21 Comment(2)
Any luck on finding a solution yet? For me the problem is that shares originating from a reshareContext don't allow me to access the /images endpoint. The only way to do this is by projection.. which isn't possible in the coming future..Unicef
I've ran into this problem too trying to get the media along with the postsGowen
C
1

I have asked LinkedIn support about this, and per their answer, projections are no longer supported for new versioned APIs. They're deprecating projections (called response decoration) in favor of “additional info fields”. To quote the November changelog:

Deprecating API decoration: Starting with the 202211 version, we will no longer support API Decoration for the adAccounts, adCampaigns and adCampaignGroups APIs; we will deprecate API Decoration for other APIs in future versions. To replace API Decoration, we are introducing additional fields in the schemas. […]

So unless or until they add these additional info fields to obtain author information with the response, you will have to perform additional requests for profile information yourself.

Each post contains an author property with an URN (for example: urn:li:organization:2414183 or urn:li:person:123). As suggested by Kapitein Witbaard in the other answer, you can retrieve details either from the organizations lookup endpoint or the profile API (the latter being still an unversioned endpoint and a subject to more restricted access).

But to make things confusing, response decorations on Organizations Lookup endpoints are still supported. Note also that you will have to parse the numeric organization ID from the URN yourself, as the endpoint doesn't accept URNs.

So given organizations with IDs 79988552 and 2414183, to retrieve their profile name along with their logo, you can use the following request:

GET https://api.linkedin.com/rest/organizationsLookup?ids=List(2414183,79988552)&projection=(results(*(id,vanityName,localizedName,logoV2(original~:playableStreams,cropped~:playableStreams,cropInfo))))

Videos and images are similar: the post can reference either media content or multiImage. You get either urn:li:video:* or urn:li:image:* URNs and you can dereference them through Video or Image APIs respectively. For these endpoints, response decoration is no longer needed and you can use batch retrievals as well.

Collum answered 11/4, 2023 at 14:26 Comment(0)
U
-1

You could look at the returned author field and determine if it is of the format:

PersonURN: /^urn:li:person:[a-z0-9]+$/i

Organization urn: /^urn:li:organization:[0-9]+$/

For organizations use the organization lookup API You cannot use the organization endpoint for it.

For persons use the profile API

Unicef answered 13/2, 2023 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.