Get project notification scheme

Gets a [notification scheme](https://confluence.atlassian.com/x/8YdKLg) associated with the project. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg).

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 project notification scheme
8
 * Gets a [notification scheme](https://confluence.atlassian.com/x/8YdKLg) associated with the project.
9

10
**[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg).
11
 */
12
export async function main(
13
  auth: Jira,
14
  projectKeyOrId: string,
15
  expand: string | undefined
16
) {
17
  const url = new URL(
18
    `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectKeyOrId}/notificationscheme`
19
  );
20
  for (const [k, v] of [["expand", expand]]) {
21
    if (v !== undefined && v !== "") {
22
      url.searchParams.append(k, v);
23
    }
24
  }
25
  const response = await fetch(url, {
26
    method: "GET",
27
    headers: {
28
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
29
    },
30
    body: undefined,
31
  });
32
  if (!response.ok) {
33
    const text = await response.text();
34
    throw new Error(`${response.status} ${text}`);
35
  }
36
  return await response.json();
37
}
38