AYONDIP JANA
AYONDIP JANA

Reputation: 81

How to get other member's profile details from linkedin api

I am trying to fetch users details from linkedIn api. After generating accesstoken I can get my details from linkedIn api but I want to get other members details. How to get this work? please help me.

I have tried the solutions according to the documentation. As per the documentation we have to sent a get request to the GET https://api.linkedin.com/rest/people/(id:{person ID}) to Retrieve Other Member's Profile. When I am sending the get request it is showing me

data: {
      code: 'VERSION_MISSING',
      message: 'A version must be present. Please specify a version by adding the LinkedIn-Version header.'
    }

this error. after searching the documentation I found that there is a note saying

in order to make the sample calls above succeed, you must include X-RestLi-Protocol-Version:2.0.0 in your request header.

I have added that to and still getting the error.

Upvotes: 7

Views: 10023

Answers (6)

Kheersagar patel
Kheersagar patel

Reputation: 523

You need to pass LinkedIn-Version header as per below example:

# Before
headers: {
  "Content-Type": "application/json",
  Authorization: `Bearer ${req.body.accessToken}`,
},

# Now
headers: {
  "Content-Type": "application/json",
  Authorization: `Bearer ${req.body.accessToken}`,
  "LinkedIn-Version": "202401",
},

How to get LinkedIn-Version from LinkedIn?

Go to https://www.linkedin.com/developers/apps/<appid>/products/share-on-linkedin/endpoints where you need to replace <appid> with you application id provided by linkedin which should look like 224036728.

Then you will get Product version: as per below screenshot which you need to pass while calling api. Product Version

source: https://developers.knowivate.com/@kheersagar/a-version-must-be-present-please-specify-a-version-by-adding-the-linkedin-version-header

Upvotes: 0

Ekta Tandel
Ekta Tandel

Reputation: 1

This version worked for me: 202204.01

Then I got: "code": "EMPTY_ACCESS_TOKEN", "message": "Empty oauth2 access token"

Which I think can be fixed by getting the access token by implementing the 3-legged OAuth. I have successfully implemented that for getting someone's profile but I am doing this for getting org info

Upvotes: 0

yabood
yabood

Reputation: 171

You need to pass the version number like this: LinkedIn-Version: 202210. It worked for me without changing /rest to /v2. More info here: Introducing API Versioning and New Content APIs.

Upvotes: 4

Karan Jain
Karan Jain

Reputation: 1

I'm also facing the same issue but you can use this https://api.linkedin.com/v2/me and it will work

Upvotes: 0

tom
tom

Reputation: 11

I had the same problem.

As the error says, I tried using LinkedIn-Version as the header key and got:

{
    "code": "INVALID_VERSION",
    "message": "API versions should have date format as YYYYMM or YYYYMM.RR where RR is the revision"
}

With the header value being: 2.0.0

Request example picture

So I tried sending as value: 202201.01 ==> YYYY=2022, MM=01, RR=01

  • YYYY: year
  • MM: month
  • RR: revision

Request with new value example picture

Obtaining:

{
    "code": "NONEXISTENT_VERSION",
    "message": "Requested version 20220101 is not active"
}

Trying some different dates and revision codes, I got to value = 202204.01 that gave me:

{
"serviceErrorCode": 100,
"code": "ACCESS_DENIED",
"message": "Not enough permissions to access: me.GET.20220401"
}

Upvotes: 0

maxicano447
maxicano447

Reputation: 113

I experienced the same issue. After some browsing this works for me:

Use https://api.linkedin.com/v2/me instead of https://api.linkedin.com/rest/me

Upvotes: 9

Related Questions