Get all project roles

Gets a list of all project roles, complete with project role details and default actors.

Script jira Verified

by hugo697 ยท 11/2/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 396 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Get all project roles
8
 * Gets a list of all project roles, complete with project role details and default actors.
9
 */
10
export async function main(auth: Jira) {
11
  const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/role`);
12

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