Delete Resource Collection
One script reply has been approved by the moderators Verified

Deletes a specified resource collection.

The response includes a job status for deletion of the collection's resources.

Allowed for

  • Admins
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
 * Delete Resource Collection
8
 * Deletes a specified resource collection.
9

10
The response includes a job
11
status for deletion of the collection's resources.
12

13
#### Allowed for
14

15
* Admins
16

17
 */
18
export async function main(auth: Zendesk, resource_collection_id: string) {
19
  const url = new URL(
20
    `https://${auth.subdomain}.zendesk.com/api/v2/resource_collections/${resource_collection_id}`
21
  );
22

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