Show Many Organizations

Accepts a comma-separated list of up to 100 organization ids or external ids. #### Allowed For * Admins * Agents

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Show Many Organizations
8
 * Accepts a comma-separated list of up to 100 organization ids or external ids.
9

10
#### Allowed For
11

12
* Admins
13
* Agents
14

15
 */
16
export async function main(
17
  auth: Zendesk,
18
  ids: string | undefined,
19
  external_ids: string | undefined
20
) {
21
  const url = new URL(
22
    `https://${auth.subdomain}.zendesk.com/api/v2/organizations/show_many`
23
  );
24
  for (const [k, v] of [
25
    ["ids", ids],
26
    ["external_ids", external_ids],
27
  ]) {
28
    if (v !== undefined && v !== "") {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45