Last updated Nov 22, 2024

JIRA Developer Documentation : JIRA REST API Example - Edit issues

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

Field meta-data

The editable fields and the operations they support can be obtained using the "editmeta" resource, e.g.

1
2
http://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.

Examples of updating an issue using fields.

Example of assigning an issue to user "harry"

This simple edit

Request
1
2
curl -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"}
   }
}
Response

You should just receive a response with a status of "204 No Content"

Example of updating many fields at the same time

Here we update the assignee and also the summary, priority, and two custom fields.

Request
1
2
curl -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"}
    }
}
Response

You should just receive a response with a status of "204 No Content"

Examples of updating a field using operations.

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.

Adding a component

Request
1
2
curl -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"}}]
   }
}
Response

You should just receive a response with a status of "204 No Content"

Setting the components field

Request
1
2
curl -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"}]}]
    }
}
Response

You should just receive a response with a status of "204 No Content"

Adding a component and removing another

Request
1
2
curl -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.

Response

You should just receive a response with a status of "204 No Content"

Manipulating multiple fields

Request
1
2
curl -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"}]
    }
}
Response

You should just receive a response with a status of "204 No Content"

Rate this page: