0

Update Many Variants

by
Published Nov 7, 2023

Updates one or more variants. See Update Variant. You must specify the variants by id in the body. To get the variant ids, see List Variants. #### Allowed For * Admins, Agents

Script zendesk Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 398 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Update Many Variants
8
 * Updates one or more variants. See Update Variant.
9

10
You must specify the variants by id in the body. To get the variant ids, see List Variants.
11

12
#### Allowed For
13

14
* Admins, Agents
15

16
 */
17
export async function main(auth: Zendesk, dynamic_content_item_id: string) {
18
  const url = new URL(
19
    `https://${auth.subdomain}.zendesk.com/api/v2/dynamic_content/items/${dynamic_content_item_id}/variants/update_many`
20
  );
21

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