0

Get issue type property

by
Published Nov 2, 2023

Returns the key and value of the [issue type property](https://developer.

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 type property
    8
     * Returns the key and value of the [issue type property](https://developer.
    9
     */
    10
    export async function main(
    11
      auth: Jira,
    12
      issueTypeId: string,
    13
      propertyKey: string
    14
    ) {
    15
      const url = new URL(
    16
        `https://${auth.domain}.atlassian.net/rest/api/2/issuetype/${issueTypeId}/properties/${propertyKey}`
    17
      );
    18
    
    
    19
      const response = await fetch(url, {
    20
        method: "GET",
    21
        headers: {
    22
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    23
        },
    24
        body: undefined,
    25
      });
    26
      if (!response.ok) {
    27
        const text = await response.text();
    28
        throw new Error(`${response.status} ${text}`);
    29
      }
    30
      return await response.json();
    31
    }
    32