Get the default data classification level of a project

Returns the default data classification for a project. **[Permissions](#permissions) required:** * *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project. * *Administer jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).

Script jira Verified

by hugo697 ยท 3/6/2024

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 the default data classification level of a project
8
 * Returns the default data classification for a project.
9

10
**[Permissions](#permissions) required:**
11

12
 *  *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
13
 *  *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
14
 *  *Administer jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
15
 */
16
export async function main(auth: Jira, projectIdOrKey: string) {
17
  const url = new URL(
18
    `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/classification-level/default`
19
  );
20

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