Get all statuses
One script reply has been approved by the moderators Verified

Returns a list of all statuses associated with active workflows.

This operation can be accessed anonymously.

Permissions required: None.

Created by hugo697 879 days ago Picked 2 times
Submitted by hugo697 Typescript (fetch-only)
Verified 327 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Get all statuses
8
 * Returns a list of all statuses associated with active workflows.
9

10
This operation can be accessed anonymously.
11

12
**[Permissions](#permissions) required:** None.
13
 */
14
export async function main(auth: Jira) {
15
  const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/status`);
16

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