Unarchive issue(s) by issue keys/ID

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

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
 * Unarchive issue(s) by issue keys/ID
8
 * Enables admins to unarchive up to 1000 issues in a single request using issue ID/key, returning details of the issue(s) unarchived 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/unarchive`
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