Assets with Jira REST API
Assets supports assigning Assets objects to issues via the Jira REST API. You will find examples on how to do this below.
Create Issue
URI: /rest/api/2/issue
As you can see below, you will have to use the key attribute to define the Assets object keys, when creating Issues with Assets custom field values.
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Task"
},
"customfield_10100" : [{"key" : "TEST-1"}],
"customfield_10200" : [{"key" : "TEST-1"}, {"key" : "TEST-2"}]
}
}
Update issue
URI: /rest/api/2/issue/[issueKey]
This is an example of setting an Assets object to a specific Assets custom field. Use the attribute set to define the Assets object keys
{
"update" : {
"customfield_10200" : [{"set": [{"key" : "TEST-1"}]}]
}
}
This is an example of adding an Assets object to the existing connected ones. Use the attribute add to define the Assets object keys
{
"update" : {
"customfield_10200" : [{"add": [{"key" : "TEST-2"},{"key" : "TEST-3"}]}]
}
}
This is an example of removing an Assets object from the existing connected ones. Use the attribute remove to define the Assets object keys
{
"update" : {
"customfield_10200" : [{"remove": [{"key" : "TEST-2"}]}]
}
}
All Assets custom fields are using arrays of keys, even if you only work with single Assets custom fields. In that case, the array will only contain a list of one (1) Assets object.