Fetch Ad Account
One script reply has been approved by the moderators Verified

Fetches an individual adAccount given its id. See the docs here

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

6
export async function main(resource: Linkedin, adAccountID: string) {
7
	const endpoint = `https://api.linkedin.com/rest/adAccounts/${adAccountID}`
8

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

18
	if (!response.ok) {
19
		throw new Error(`HTTP error! status: ${response.status}`)
20
	}
21

22
	const data = await response.json()
23

24
	return data
25
}
26