1 | type Jira = { |
2 | username: string; |
3 | password: string; |
4 | domain: string; |
5 | }; |
6 | |
7 | * Create custom field |
8 | * Creates a custom field. |
9 |
|
10 | **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg). |
11 | */ |
12 | export async function main( |
13 | auth: Jira, |
14 | body: { |
15 | description?: string; |
16 | name: string; |
17 | searcherKey?: |
18 | | "com.atlassian.jira.plugin.system.customfieldtypes:cascadingselectsearcher" |
19 | | "com.atlassian.jira.plugin.system.customfieldtypes:daterange" |
20 | | "com.atlassian.jira.plugin.system.customfieldtypes:datetimerange" |
21 | | "com.atlassian.jira.plugin.system.customfieldtypes:exactnumber" |
22 | | "com.atlassian.jira.plugin.system.customfieldtypes:exacttextsearcher" |
23 | | "com.atlassian.jira.plugin.system.customfieldtypes:grouppickersearcher" |
24 | | "com.atlassian.jira.plugin.system.customfieldtypes:labelsearcher" |
25 | | "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" |
26 | | "com.atlassian.jira.plugin.system.customfieldtypes:numberrange" |
27 | | "com.atlassian.jira.plugin.system.customfieldtypes:projectsearcher" |
28 | | "com.atlassian.jira.plugin.system.customfieldtypes:textsearcher" |
29 | | "com.atlassian.jira.plugin.system.customfieldtypes:userpickergroupsearcher" |
30 | | "com.atlassian.jira.plugin.system.customfieldtypes:versionsearcher"; |
31 | type: string; |
32 | } |
33 | ) { |
34 | const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/field`); |
35 |
|
36 | const response = await fetch(url, { |
37 | method: "POST", |
38 | headers: { |
39 | "Content-Type": "application/json", |
40 | Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`), |
41 | }, |
42 | body: JSON.stringify(body), |
43 | }); |
44 | if (!response.ok) { |
45 | const text = await response.text(); |
46 | throw new Error(`${response.status} ${text}`); |
47 | } |
48 | return await response.json(); |
49 | } |
50 |
|