Applicable: | JIRA 5.0 and later. |
The Rest API allows you to add edit and remove issue comments.
Comments may be added either via the rest/api/2/issue/{issuekey}/comment
resource or as part of editing 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
This resource simply adds a comment and nothing else. (It is also possible to add a comment as a side-effect of another operation like "edit issue" or "transition issue"). This resource is particularly useful if the logged in user may not have "edit" permission for the issue, but does have the "add comment" permission.
1 2curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31/comment
example input data
1 2{ "body": "This is a comment regarding the quality of the response." }
You should just receive a response with a status of "201" with the full json representation of the added comment
1 2curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31/comment
example input data
1 2{ "body": "This is a comment that only administrators can see.", "visibility": { "type": "role", "value": "Administrators" } }
Comments can also be added using the normal edit operations
Here we update the description and add a comment saying why.
Only one comment can be added at a time when updating an issue via this resource.
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": { "comment": [ { "add": { "body": "It is time to finish this task" } } ] } }
Here we update the description and add a comment saying why.
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": { "description": [ { "set": "JIRA should also come with a free pony" } ], "comment": [ { "add": { "body": "This request was originally written in French, which most of our developers can't read" } } ] } }
Rate this page: