Get all issue type schemes

Returns a [paginated](#pagination) list of issue type schemes. Only issue type schemes used in classic projects are returned. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).

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 issue type schemes
8
 * Returns a [paginated](#pagination) list of issue type schemes.
9

10
Only issue type schemes used in classic projects are returned.
11

12
**[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
13
 */
14
export async function main(
15
  auth: Jira,
16
  startAt: string | undefined,
17
  maxResults: string | undefined,
18
  id: string | undefined,
19
  orderBy: "name" | "-name" | "+name" | "id" | "-id" | "+id" | undefined,
20
  expand: string | undefined,
21
  queryString: string | undefined
22
) {
23
  const url = new URL(
24
    `https://${auth.domain}.atlassian.net/rest/api/2/issuetypescheme`
25
  );
26
  for (const [k, v] of [
27
    ["startAt", startAt],
28
    ["maxResults", maxResults],
29
    ["id", id],
30
    ["orderBy", orderBy],
31
    ["expand", expand],
32
    ["queryString", queryString],
33
  ]) {
34
    if (v !== undefined && v !== "") {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "GET",
40
    headers: {
41
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
42
    },
43
    body: undefined,
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51