Delete issue link type

Deletes an issue link type. To use this operation, the site must have [issue linking](https://confluence.atlassian.com/x/yoXKM) enabled. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).

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
 * Delete issue link type
8
 * Deletes an issue link type.
9

10
To use this operation, the site must have [issue linking](https://confluence.atlassian.com/x/yoXKM) enabled.
11

12
**[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
13
 */
14
export async function main(auth: Jira, issueLinkTypeId: string) {
15
  const url = new URL(
16
    `https://${auth.domain}.atlassian.net/rest/api/2/issueLinkType/${issueLinkTypeId}`
17
  );
18

19
  const response = await fetch(url, {
20
    method: "DELETE",
21
    headers: {
22
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.text();
31
}
32