0

Bulk set issue properties by issue

by
Published Nov 2, 2023

Sets or updates entity property values on issues.

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
     * Bulk set issue properties by issue
    8
     * Sets or updates entity property values on issues.
    9
     */
    10
    export async function main(
    11
      auth: Jira,
    12
      body: {
    13
        issues?: {
    14
          issueID?: number;
    15
          properties?: {
    16
            [k: string]: {
    17
              array?: boolean;
    18
              bigDecimal?: boolean;
    19
              bigInteger?: boolean;
    20
              bigIntegerValue?: number;
    21
              binary?: boolean;
    22
              binaryValue?: string[];
    23
              boolean?: boolean;
    24
              booleanValue?: boolean;
    25
              containerNode?: boolean;
    26
              decimalValue?: number;
    27
              double?: boolean;
    28
              doubleValue?: number;
    29
              elements?: { [k: string]: unknown };
    30
              fieldNames?: { [k: string]: unknown };
    31
              fields?: { [k: string]: unknown };
    32
              floatingPointNumber?: boolean;
    33
              int?: boolean;
    34
              intValue?: number;
    35
              integralNumber?: boolean;
    36
              long?: boolean;
    37
              longValue?: number;
    38
              missingNode?: boolean;
    39
              null?: boolean;
    40
              number?: boolean;
    41
              numberType?:
    42
                | "INT"
    43
                | "LONG"
    44
                | "BIG_INTEGER"
    45
                | "FLOAT"
    46
                | "DOUBLE"
    47
                | "BIG_DECIMAL";
    48
              numberValue?: number;
    49
              object?: boolean;
    50
              pojo?: boolean;
    51
              textValue?: string;
    52
              textual?: boolean;
    53
              valueAsBoolean?: boolean;
    54
              valueAsDouble?: number;
    55
              valueAsInt?: number;
    56
              valueAsLong?: number;
    57
              valueAsText?: string;
    58
              valueNode?: boolean;
    59
            };
    60
          };
    61
        }[];
    62
      }
    63
    ) {
    64
      const url = new URL(
    65
        `https://${auth.domain}.atlassian.net/rest/api/2/issue/properties/multi`
    66
      );
    67
    
    
    68
      const response = await fetch(url, {
    69
        method: "POST",
    70
        headers: {
    71
          "Content-Type": "application/json",
    72
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
    73
        },
    74
        body: JSON.stringify(body),
    75
      });
    76
      if (!response.ok) {
    77
        const text = await response.text();
    78
        throw new Error(`${response.status} ${text}`);
    79
      }
    80
      return await response.text();
    81
    }
    82