Cannot add comment when transitioning an issue via API v3

Antolene Capili
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 9, 2020

V3 endpoint:

/rest/api/3/issue/MAB-4/transitions'

V3 request body (copy-pasted from docs):

{
"update": {
"comment": [
{
"add": {
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Bug has been fixed",
"type": "text"
}
]
}
]
}
}
}
]
},
"transition": {
"id": "61"
}
}

 Doing a POST request to the above endpoint results to this (with a 404 status code):

{"errorMessages":[],"errors":{"comment":"Comment body is not valid!"}}

 

With v2 API, transitioning an issue with a comment works fine, i.e.,

Endpoint:

/rest/api/2/issue/MAB-4/transitions

Request Body:

{
"update": {
"comment": [
{
"add": {
"body": "Eto ay comment gamit ang v2 API"
}
}
]
},
"transition": {
"id": "61"
}
}

 

3 answers

0 votes
Luiz-F Ferreira January 29, 2022

Hi, all!

I had the same issue and I found the solution on a similar post here on the community:

https://community.atlassian.com/t5/Jira-questions/add-a-comment-while-changing-issue-status-by-REST/qaq-p/590930

It turns out you are only able to "update/add" a comment trough API transition when you require a comment also on the UI!

I've managed to make it work with the api v3 using the same solution. 

I've added an empty screen on the transition and a field required validator for the comment (the second one is not mandatory, probably, but I needed it for my workflow)

Justin Drawz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 3, 2022
when you require a comment also on the UI

What do you mean by the above?

Luiz-F Ferreira February 3, 2022

Hi, Justin!

If you add an empty screen to your transition, a pop up will show during the transition with a "comments" field, similar to the one on the main issue screen, enabling the input of a comment during the transition.

The comment made on that pop up is effectively added the issue on the 2o step of the transition post-functions.

To see the parts that a I mention above, these are the steps, at least for Jira Cloud:

  1. Open the Workflow edit screen.
  2. Select the transition you wish to add the comment.
  3. Click on the "Edit" button.
  4. A pop up will show with three options, "Name"; "Description" and "Screen".
  5. Select an empty screen on the picklist.
  6. Click save to close the pop up and publish the workflow

When you try to transition the issue using the configured transition, the mentioned "Comment" popup will show. 

If that pop up shows using the graphical interface (UI), then you should be able to update de comment during the API transition, too!

0 votes
Hiran
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 25, 2022

Same issue here, transition is triggered but no comments are added.

0 votes
Chris McGuire April 13, 2020

Same issue.  I'm getting error 400, bad request.  My request looks exactly like your example

UPDATE: 

I have managed to get the transition to fire, but the comment is not posting.  On v2 (separate subject), I'm unable to get the "visibility" to set, even though the request goes through.  

Suggest an answer

Log in or Sign up to answer