How to use POST on the Feature/Epic custom fields in the Jira Align API v2
Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
With the release of v.10.104.x, we support Custom Fields for Epics and Features in the REST API v2.
This article outlines how to update the values using the API POST command.
Solution
First of all, it is good to run the call to the editmeta endpoint, as it will bring the information needed on the custom field and its type, which is necessary to be used on the PATCH. This endpoint can be found for Epics at:
1
<https://<instance>.jiraalign.com/rest/align/api/2/Epics/<id>/editmeta>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[
{
"customfield_70026": {
"required": false,
"name": "Text Question 1",
"schema": {
"type": "string",
"customId": 70026
},
"key": "customfield_70026"
}
},
{
"customfield_70027": {
"required": false,
"name": "Dropdown Question 2",
"allowedValues": [
{
"id": 33,
"value": "DQ2 Answer 1"
},
{
"id": 34,
"value": "DQ2 Answer 2"
}
],
"schema": {
"type": "option",
"customId": 70027
},
"key": "customfield_70027"
}
}
]
The field customfields is an array that holds the position (and values) of all the customfield_xxxxx inside of it, to be able to access these elements individually, the position inside the array needs to be provided. Keep in mind that this array starts at position 0.
Using the editmeta output from the above example, field customfield_70026 is on position 0 of array customfields, as customfield_70027 is on position 1.
Also, as this is a structure of JSON (so you have elements inside elements), the fields customfield_xxxxx can also be arrays themselves and will have their values inside of specific positions. Due to this, it is important to get the editmeta output to be able to understand its structure and how to manipulate it.
Custom Field type Text
For a text type, we can simply add it like the below on the normal JSON body that would be used:
1
2
3
4
5
6
7
8
9
10
11
"customFields":
[
{
"customfield_80060":
[
{
"value": "my test"
}
]
}
]
If we use a complete request, it would look like this for Features:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
"title": "Diego Test Feature Created by API 1",
"description": "Diego Test Feature Created by API 1",
"releaseId": null,
"ownerId": "661727",
"state": 0,
"createDate": "2022-05-12T14:52:15Z",
"type": 1,
"mmf": 0,
"isBlocked": 0,
"priority": null,
"primaryProgramId": 196,
"productId": null,
"isMultiProgram": null,
"themeId": null,
"parentId": null,
"reportColor": "#046895",
"startSprintId": null,
"endSprintId": null,
"targetCompletionDate": null,
"startInitiationDate": null,
"portfolioAskDate": null,
"featureSummary": "Diego Test Epic to Break Integration 6",
"customFields":
[
{
"customfield_90690":
[
{
"value": "Diego Test Custom String Field 1"
}
]
}
]
}
The POST command would be similar to:
1
curl -k -X POST "https://alignsupport.jiraalign.com/rest/align/api/2/Feature/{id}" -H "accept: */*" -H "Authorization: bearer {TOKEN}" -H "Content-Type: application/json;odata.metadata=minimal;odata.streaming=true" -d "@{CONTENT_FILE}"
Custom Field type Dropdown
The POST for Dropdown fields is similar, with the difference that we need to add the id of the option as the value (this can be seen on the editmeta output as well), on this example, the field updated is customfield_90756 :
1
2
3
4
5
6
7
8
9
"customFields": [
{
"customfield_90756": [
{
"id": 18,
}
]
}
]
A complete request would look like this for Features:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"title": "Diego Test Feature Created by API 1",
"description": "Diego Test Feature Created by API 1",
"releaseId": null,
"ownerId": "661727",
"state": 0,
"createDate": "2022-05-12T14:52:15Z",
"type": 1,
"mmf": 0,
"isBlocked": 0,
"priority": null,
"primaryProgramId": 196,
"productId": null,
"isMultiProgram": null,
"themeId": null,
"parentId": null,
"reportColor": "#046895",
"startSprintId": null,
"endSprintId": null,
"targetCompletionDate": null,
"startInitiationDate": null,
"portfolioAskDate": null,
"featureSummary": "Diego Test Epic to Break Integration 6",
"customFields": [
{
"customfield_90756": [
{
"id": 18,
}
]
}
}
Using the POST command like the previous one.
With Both types:
One simple example with both types would look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"customFields": [
{
"customfield_90692": null
},
{
"customfield_90756": [
{
"id": 18,
}
]
},
{
"customfield_90690": [
{
"value": "Diego Test Custom String Field 1"
}
]
},
{
"customfield_90691": null
}
]
Was this helpful?