0

List Objects

by
Published 8 days ago

List all objects available in the org (global describe), with their labels, API names, and capabilities (queryable, createable, custom).

Script salesforce Verified

The script

Submitted by hugo989 Bun
Verified 9 days ago
1
//native
2

3
/**
4
 * List Objects
5
 * List all objects available in the org (global describe), with their labels, API names, and capabilities (queryable, createable, custom).
6
 */
7
export async function main(auth: RT.Salesforce) {
8
  const apiVersion = auth.api_version || "v60.0"
9
  const url = new URL(
10
    `${auth.instance_url}/services/data/${apiVersion}/sobjects/`
11
  )
12

13
  const response = await fetch(url, {
14
    method: "GET",
15
    headers: {
16
      Authorization: `Bearer ${auth.token}`,
17
      Accept: "application/json",
18
    },
19
  })
20

21
  if (!response.ok) {
22
    throw new Error(`${response.status} ${await response.text()}`)
23
  }
24

25
  return await response.json()
26
}
27