0

Get screen schemes

by
Published Nov 2, 2023

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

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 527 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Get screen schemes
    8
     * Returns a [paginated](#pagination) list of screen schemes.
    9
    
    
    10
    Only screen 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
      expand: string | undefined,
    20
      queryString: string | undefined,
    21
      orderBy: "name" | "-name" | "+name" | "id" | "-id" | "+id" | undefined
    22
    ) {
    23
      const url = new URL(
    24
        `https://${auth.domain}.atlassian.net/rest/api/2/screenscheme`
    25
      );
    26
      for (const [k, v] of [
    27
        ["startAt", startAt],
    28
        ["maxResults", maxResults],
    29
        ["id", id],
    30
        ["expand", expand],
    31
        ["queryString", queryString],
    32
        ["orderBy", orderBy],
    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