List Items
One script reply has been approved by the moderators Verified

Returns a list of all dynamic content items for your account if accessed as an admin or agents who have permission to manage dynamic content.

Allowed For

  • Admins, Agents
Created by hugo697 844 days ago
Submitted by hugo697 Typescript (fetch-only)
Verified 298 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * List Items
8
 * Returns a list of all dynamic content items for your account if accessed as an admin or agents who have permission to manage dynamic content.
9

10
#### Allowed For
11

12
* Admins, Agents
13

14
 */
15
export async function main(auth: Zendesk) {
16
  const url = new URL(
17
    `https://${auth.subdomain}.zendesk.com/api/v2/dynamic_content/items`
18
  );
19

20
  const response = await fetch(url, {
21
    method: "GET",
22
    headers: {
23
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33