Bulk get workflow schemes

Returns a list of workflow schemes by providing workflow scheme IDs or project IDs. **[Permissions](#permissions) required:** * *Administer Jira* global permission to access all, including project-scoped, workflow schemes * *Administer projects* project permissions to access project-scoped workflow schemes

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
 * Bulk get workflow schemes
8
 * Returns a list of workflow schemes by providing workflow scheme IDs or project IDs.
9

10
**[Permissions](#permissions) required:**
11

12
 *  *Administer Jira* global permission to access all, including project-scoped, workflow schemes
13
 *  *Administer projects* project permissions to access project-scoped workflow schemes
14
 */
15
export async function main(
16
  auth: Jira,
17
  expand: string | undefined,
18
  body: { projectIds?: string[]; workflowSchemeIds?: string[] }
19
) {
20
  const url = new URL(
21
    `https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/read`
22
  );
23
  for (const [k, v] of [["expand", expand]]) {
24
    if (v !== undefined && v !== "") {
25
      url.searchParams.append(k, v);
26
    }
27
  }
28
  const response = await fetch(url, {
29
    method: "POST",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
33
    },
34
    body: JSON.stringify(body),
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42