Show Request

#### Sideloads The following sideloads are supported: | Name | Will sideload | ---------------- | ------------- | users | The email ccs for a request by side-loading users #### Allowed For * End Users

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 Request
8
 * #### Sideloads
9

10
The following sideloads are supported:
11

12
| Name             | Will sideload
13
| ---------------- | -------------
14
| users            | The email ccs for a request by side-loading users
15

16
#### Allowed For
17

18
* End Users
19

20
 */
21
export async function main(auth: Zendesk, request_id: string) {
22
  const url = new URL(
23
    `https://${auth.subdomain}.zendesk.com/api/v2/requests/${request_id}`
24
  );
25

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