Bulk set issues properties by list

Sets or updates a list of entity property values on issues.

Script jira Verified

by hugo697 ยท 11/2/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 396 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Bulk set issues properties by list
8
 * Sets or updates a list of entity property values on issues.
9
 */
10
export async function main(
11
  auth: Jira,
12
  body: {
13
    entitiesIds?: number[];
14
    properties?: {
15
      [k: string]: {
16
        array?: boolean;
17
        bigDecimal?: boolean;
18
        bigInteger?: boolean;
19
        bigIntegerValue?: number;
20
        binary?: boolean;
21
        binaryValue?: string[];
22
        boolean?: boolean;
23
        booleanValue?: boolean;
24
        containerNode?: boolean;
25
        decimalValue?: number;
26
        double?: boolean;
27
        doubleValue?: number;
28
        elements?: { [k: string]: unknown };
29
        fieldNames?: { [k: string]: unknown };
30
        fields?: { [k: string]: unknown };
31
        floatingPointNumber?: boolean;
32
        int?: boolean;
33
        intValue?: number;
34
        integralNumber?: boolean;
35
        long?: boolean;
36
        longValue?: number;
37
        missingNode?: boolean;
38
        null?: boolean;
39
        number?: boolean;
40
        numberType?:
41
          | "INT"
42
          | "LONG"
43
          | "BIG_INTEGER"
44
          | "FLOAT"
45
          | "DOUBLE"
46
          | "BIG_DECIMAL";
47
        numberValue?: number;
48
        object?: boolean;
49
        pojo?: boolean;
50
        textValue?: string;
51
        textual?: boolean;
52
        valueAsBoolean?: boolean;
53
        valueAsDouble?: number;
54
        valueAsInt?: number;
55
        valueAsLong?: number;
56
        valueAsText?: string;
57
        valueNode?: boolean;
58
      };
59
    };
60
  }
61
) {
62
  const url = new URL(
63
    `https://${auth.domain}.atlassian.net/rest/api/2/issue/properties`
64
  );
65

66
  const response = await fetch(url, {
67
    method: "POST",
68
    headers: {
69
      "Content-Type": "application/json",
70
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
71
    },
72
    body: JSON.stringify(body),
73
  });
74
  if (!response.ok) {
75
    const text = await response.text();
76
    throw new Error(`${response.status} ${text}`);
77
  }
78
  return await response.text();
79
}
80