0

Get group

Published Nov 2, 2023

This operation is deprecated, use [`group/member`](#api-rest-api-2-group-member-get). Returns all users in a group. **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 567 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Get group
    8
     * This operation is deprecated, use [`group/member`](#api-rest-api-2-group-member-get).
    9
    
    
    10
    Returns all users in a group.
    11
    
    
    12
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
    13
     */
    14
    export async function main(
    15
      auth: Jira,
    16
      groupname: string | undefined,
    17
      groupId: string | undefined,
    18
      expand: string | undefined
    19
    ) {
    20
      const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/group`);
    21
      for (const [k, v] of [
    22
        ["groupname", groupname],
    23
        ["groupId", groupId],
    24
        ["expand", expand],
    25
      ]) {
    26
        if (v !== undefined && v !== "") {
    27
          url.searchParams.append(k, v);
    28
        }
    29
      }
    30
      const response = await fetch(url, {
    31
        method: "GET",
    32
        headers: {
    33
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    34
        },
    35
        body: undefined,
    36
      });
    37
      if (!response.ok) {
    38
        const text = await response.text();
    39
        throw new Error(`${response.status} ${text}`);
    40
      }
    41
      return await response.json();
    42
    }
    43