0

Get component issues count

Published Nov 2, 2023

Returns the counts of issues assigned to the component. This operation can be accessed anonymously. **Deprecation notice:** The required OAuth 2.0 scopes will be updated on June 15, 2024. * **Classic**: `read:jira-work` * **Granular**: `read:field:jira`, `read:project.component:jira` **[Permissions](#permissions) required:** None.

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 565 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Get component issues count
    8
     * Returns the counts of issues assigned to the component.
    9
    
    
    10
    This operation can be accessed anonymously.
    11
    
    
    12
    **Deprecation notice:** The required OAuth 2.0 scopes will be updated on June 15, 2024.
    13
    
    
    14
     *  **Classic**: `read:jira-work`
    15
     *  **Granular**: `read:field:jira`, `read:project.component:jira`
    16
    
    
    17
    **[Permissions](#permissions) required:** None.
    18
     */
    19
    export async function main(auth: Jira, id: string) {
    20
      const url = new URL(
    21
        `https://${auth.domain}.atlassian.net/rest/api/2/component/${id}/relatedIssueCounts`
    22
      );
    23
    
    
    24
      const response = await fetch(url, {
    25
        method: "GET",
    26
        headers: {
    27
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    28
        },
    29
        body: undefined,
    30
      });
    31
      if (!response.ok) {
    32
        const text = await response.text();
    33
        throw new Error(`${response.status} ${text}`);
    34
      }
    35
      return await response.json();
    36
    }
    37