List Job Statuses

Shows the statuses for background jobs. Statuses are sorted first by completion date and then by creation date in descending order. #### Allowed For: * Agents #### Pagination * Cursor pagination See Pagination. Returns a maximum of 100 records per page sorted by `completed_at desc, created_at desc`. Does not allow any other sort order.

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
 * List Job Statuses
8
 * Shows the statuses for background jobs. Statuses are sorted first by completion date and then by creation date in descending order.
9

10
#### Allowed For:
11

12
* Agents
13

14
#### Pagination
15

16
* Cursor pagination
17

18
See Pagination.
19

20
Returns a maximum of 100 records per page sorted by `completed_at desc, created_at desc`. Does not allow any other sort order.
21

22
 */
23
export async function main(auth: Zendesk) {
24
  const url = new URL(
25
    `https://${auth.subdomain}.zendesk.com/api/v2/job_statuses`
26
  );
27

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