Archive issue(s) by JQL

Enables admins to archive up to 100,000 issues in a single request using JQL, returning the URL to check the status of the submitted request.

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
 * Archive issue(s) by JQL
8
 * Enables admins to archive up to 100,000 issues in a single request using JQL, returning the URL to check the status of the submitted request.
9
 */
10
export async function main(auth: Jira, body: { jql?: 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: "POST",
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