Applicable: | JIRA 5.0 and later. |
The Rest API allows you to edit an issue.
The JIRA REST api is very flexible in how it allows you to edit an issue. You can PUT a document, an updated version of the issue you received with a GET request, or you can send commands to set or modify fields of an issue.
The examples shown here use curl with an input file denoted by the "--data @filename" syntax and the file data is shown separately
The editable fields and the operations they support can be obtained using the "editmeta" resource, e.g.
1 2http://kelpie9:8081/rest/api/2/issue/XSS-13/editmeta
Note, the "editmeta" resource does not work with PUT operations. You should only use it to get data.
This simple edit
1 2curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
example input data
1 2{ "fields": { "assignee":{"name":"harry"} } }
You should just receive a response with a status of "204 No Content"
Here we update the assignee and also the summary, priority, and two custom fields.
1 2curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
example input data
1 2{ "fields" : { "customfield_10200" : {"value" : "Test 1"} , "customfield_10201" : {"value" : "Value 1"} } }
You should just receive a response with a status of "204 No Content"
The fields of an issue may also be updated in more flexible ways using the SET, ADD and REMOVE operations. Not all fields support all operations, but as a general rule single value fields support SET, whereas multi-value fields support SET, ADD and REMOVE, where SET replaces the field contents while ADD and REMOVE add or remove one or more values from the the current list of values.
1 2curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
example input data
1 2{ "update" : { "components" : [{"add" : {"name" : "Engine"}}] } }
You should just receive a response with a status of "204 No Content"
1 2curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
example input data
1 2{ "update" : { "components" : [{"set" : [{"name" : "Engine"}, {"name" : "Trans/A"}]}] } }
You should just receive a response with a status of "204 No Content"
1 2curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
example input data
1 2{ "update" : { "components" : [{"remove" : {"name" : "Trans/A"}}, {"add" : {"name" : "Trans/M"}}] } }
Note: The "Engine" component (if it exists) remains unaffected by this update.
You should just receive a response with a status of "204 No Content"
1 2curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
example input data
1 2{ "update" : { "components" : [{"remove" : {"name" : "Trans/A"}}, {"add" : {"name" : "Trans/M"}}], "assignee" : [{"set" : {"name" : "harry"}}], "summary" : [{"set" : "Big block Chevy"}] } }
You should just receive a response with a status of "204 No Content"
Rate this page: