0
Get Multiple Member Profiles
One script reply has been approved by the moderators Verified

Gets multiple member profiles at once. See the docs here

Created by hugo697 158 days ago Viewed 199 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 158 days ago
1
type Linkedin = {
2
	token: string
3
	apiVersion: string
4
}
5

6
export async function main(resource: Linkedin, personIdList: string[]) {
7
	const personIdUrl = personIdList.map((id) => `(id:${id})`).join(',')
8

9
	// https://api.linkedin.com/rest/people?ids=List((id:{Person ID1}),(id:{Person ID2}),(id:{Person ID3}))
10
	const endpoint = `https://api.linkedin.com/rest/people?ids=List(${personIdUrl})`
11

12
	const response = await fetch(endpoint, {
13
		method: 'GET',
14
		headers: {
15
			Authorization: `Bearer ${resource.token}`,
16
			'LinkedIn-Version': `${resource.apiVersion}`,
17
			'X-Restli-Protocol-Version': '2.0.0'
18
		}
19
	})
20

21
	if (!response.ok) {
22
		throw new Error(`HTTP error! status: ${response.status}`)
23
	}
24

25
	const data = await response.json()
26

27
	return data
28
}
29