0

Get issue property

by
Published Nov 2, 2023

Returns the key and value of an issue's property. This operation can be accessed anonymously. **[Permissions](#permissions) required:** * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the issue. * 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 525 days ago
    1
    type Jira = {
    2
      username: string;
    3
      password: string;
    4
      domain: string;
    5
    };
    6
    /**
    7
     * Get issue property
    8
     * Returns the key and value of an issue's property.
    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 containing the issue.
    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
      propertyKey: string
    21
    ) {
    22
      const url = new URL(
    23
        `https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueIdOrKey}/properties/${propertyKey}`
    24
      );
    25
    
    
    26
      const response = await fetch(url, {
    27
        method: "GET",
    28
        headers: {
    29
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    30
        },
    31
        body: undefined,
    32
      });
    33
      if (!response.ok) {
    34
        const text = await response.text();
    35
        throw new Error(`${response.status} ${text}`);
    36
      }
    37
      return await response.json();
    38
    }
    39