0

Create resolution

by
Published Nov 2, 2023

Creates an issue resolution. **[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 resolution
    8
     * Creates an issue resolution.
    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: { description?: string; name: string; [k: string]: unknown }
    15
    ) {
    16
      const url = new URL(
    17
        `https://${auth.domain}.atlassian.net/rest/api/2/resolution`
    18
      );
    19
    
    
    20
      const response = await fetch(url, {
    21
        method: "POST",
    22
        headers: {
    23
          "Content-Type": "application/json",
    24
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    25
        },
    26
        body: JSON.stringify(body),
    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