0

Archive issue(s) by issue ID/key

Published Nov 2, 2023

Enables admins to archive up to 1000 issues in a single request using issue ID/key, returning details of the issue(s) archived in the process and the errors encountered, if any.

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 567 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Archive issue(s) by issue ID/key
    8
     * Enables admins to archive up to 1000 issues in a single request using issue ID/key, returning details of the issue(s) archived in the process and the errors encountered, if any.
    9
     */
    10
    export async function main(auth: Jira, body: { issueIdsOrKeys?: string[] }) {
    11
      const url = new URL(
    12
        `https://${auth.domain}.atlassian.net/rest/api/2/issue/archive`
    13
      );
    14
    
    
    15
      const response = await fetch(url, {
    16
        method: "PUT",
    17
        headers: {
    18
          "Content-Type": "application/json",
    19
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    20
        },
    21
        body: JSON.stringify(body),
    22
      });
    23
      if (!response.ok) {
    24
        const text = await response.text();
    25
        throw new Error(`${response.status} ${text}`);
    26
      }
    27
      return await response.json();
    28
    }
    29