Create issue type screen scheme
One script reply has been approved by the moderators Verified

Creates an issue type screen scheme.

Permissions required: Administer Jira global permission.

Created by hugo697 879 days ago
Submitted by hugo697 Typescript (fetch-only)
Verified 327 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Create issue type screen scheme
8
 * Creates an issue type screen scheme.
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: {
15
    description?: string;
16
    issueTypeMappings: { issueTypeId: string; screenSchemeId: string }[];
17
    name: string;
18
  }
19
) {
20
  const url = new URL(
21
    `https://${auth.domain}.atlassian.net/rest/api/2/issuetypescreenscheme`
22
  );
23

24
  const response = await fetch(url, {
25
    method: "POST",
26
    headers: {
27
      "Content-Type": "application/json",
28
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
29
    },
30
    body: JSON.stringify(body),
31
  });
32
  if (!response.ok) {
33
    const text = await response.text();
34
    throw new Error(`${response.status} ${text}`);
35
  }
36
  return await response.json();
37
}
38