0
Redact String in Comment
One script reply has been approved by the moderators Verified

Permanently removes words or strings from a ticket comment.

Created by hugo697 539 days ago Viewed 20713 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 539 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Redact String in Comment
8
 * Permanently removes words or strings from a ticket comment.
9
 */
10
export async function main(
11
  auth: Zendesk,
12
  ticket_id: string,
13
  ticket_comment_id: string
14
) {
15
  const url = new URL(
16
    `https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/comments/${ticket_comment_id}/redact`
17
  );
18

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