0

Get changelogs by IDs

by
Published Nov 2, 2023

Returns changelogs for an issue specified by a list of changelog IDs. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in. * If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.

Script jira
  • Submitted by hugo697 Typescript (fetch-only)
    Created 527 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Get changelogs by IDs
    8
     * Returns changelogs for an issue specified by a list of changelog IDs.
    9
    
    
    10
    This operation can be accessed anonymously.
    11
    
    
    12
    **[Permissions](#permissions) required:**
    13
    
    
    14
     *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
    15
     *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
    16
     */
    17
    export async function main(
    18
      auth: Jira,
    19
      issueIdOrKey: string,
    20
      body: { changelogIds: number[] }
    21
    ) {
    22
      const url = new URL(
    23
        `https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueIdOrKey}/changelog/list`
    24
      );
    25
    
    
    26
      const response = await fetch(url, {
    27
        method: "POST",
    28
        headers: {
    29
          "Content-Type": "application/json",
    30
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    31
        },
    32
        body: JSON.stringify(body),
    33
      });
    34
      if (!response.ok) {
    35
        const text = await response.text();
    36
        throw new Error(`${response.status} ${text}`);
    37
      }
    38
      return await response.json();
    39
    }
    40