0

Create notification scheme

by
Published Nov 2, 2023

Creates a notification scheme with notifications. You can create up to 1000 notifications per request. **[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
     * Create notification scheme
    8
     * Creates a notification scheme with notifications. You can create up to 1000 notifications per request.
    9
    
    
    10
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
    11
     */
    12
    export async function main(
    13
      auth: Jira,
    14
      body: {
    15
        description?: string;
    16
        name: string;
    17
        notificationSchemeEvents?: {
    18
          event: { id: string; [k: string]: unknown };
    19
          notifications: {
    20
            notificationType: string;
    21
            parameter?: string;
    22
            [k: string]: unknown;
    23
          }[];
    24
          [k: string]: unknown;
    25
        }[];
    26
        [k: string]: unknown;
    27
      }
    28
    ) {
    29
      const url = new URL(
    30
        `https://${auth.domain}.atlassian.net/rest/api/2/notificationscheme`
    31
      );
    32
    
    
    33
      const response = await fetch(url, {
    34
        method: "POST",
    35
        headers: {
    36
          "Content-Type": "application/json",
    37
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    38
        },
    39
        body: JSON.stringify(body),
    40
      });
    41
      if (!response.ok) {
    42
        const text = await response.text();
    43
        throw new Error(`${response.status} ${text}`);
    44
      }
    45
      return await response.json();
    46
    }
    47