0

Get issue link

Published Nov 2, 2023

Returns an issue link. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse project* [project permission](https://confluence.atlassian.com/x/yodKLg) for all the projects containing the linked issues. * If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, permission to view both of the issues.

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 issue link
    8
     * Returns an issue link.
    9
    
    
    10
    This operation can be accessed anonymously.
    11
    
    
    12
    **[Permissions](#permissions) required:**
    13
    
    
    14
     *  *Browse project* [project permission](https://confluence.atlassian.com/x/yodKLg) for all the projects containing the linked issues.
    15
     *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, permission to view both of the issues.
    16
     */
    17
    export async function main(auth: Jira, linkId: string) {
    18
      const url = new URL(
    19
        `https://${auth.domain}.atlassian.net/rest/api/2/issueLink/${linkId}`
    20
      );
    21
    
    
    22
      const response = await fetch(url, {
    23
        method: "GET",
    24
        headers: {
    25
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    26
        },
    27
        body: undefined,
    28
      });
    29
      if (!response.ok) {
    30
        const text = await response.text();
    31
        throw new Error(`${response.status} ${text}`);
    32
      }
    33
      return await response.json();
    34
    }
    35