Get bulk screen tabs

Returns the list of tabs for a bulk of screens. **[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
 * Get bulk screen tabs
8
 * Returns the list of tabs for a bulk of screens.
9

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

12
 *  *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
13
 */
14
export async function main(
15
  auth: Jira,
16
  screenId: string | undefined,
17
  tabId: string | undefined,
18
  startAt: string | undefined,
19
  maxResult: string | undefined
20
) {
21
  const url = new URL(
22
    `https://${auth.domain}.atlassian.net/rest/api/2/screens/tabs`
23
  );
24
  for (const [k, v] of [
25
    ["screenId", screenId],
26
    ["tabId", tabId],
27
    ["startAt", startAt],
28
    ["maxResult", maxResult],
29
  ]) {
30
    if (v !== undefined && v !== "") {
31
      url.searchParams.append(k, v);
32
    }
33
  }
34
  const response = await fetch(url, {
35
    method: "GET",
36
    headers: {
37
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
38
    },
39
    body: undefined,
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47