add a comment while changing issue status by REST

Ziyan Liu May 25, 2017

Hi,

I am trying to add a comment while changing issue status by rest api. 

curl -D- -u admin:admin -X POST --data @/Users/ziyan/Desktop/test.json -H "Content-Type: application/json" https://mytestingurl.atlassian.net/rest/api/2/issue/ZD-25/transitions?expand=transitions.fields

Here is the JSON:

{
    "transition": {
        "id": "61"
    },
    "update": {
        "comment": [
            {
                "add": {
                    "body": "Bug has been fixed."
                }
            }
        ]
    }
}

For some reason, I get the 204 response and have my status changed, but I am unable to add the comment. What could possibly go wrong?

Please help! Thanks

1 answer

0 votes
Brant Schroeder
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 25, 2017

I believe that you just have the order wrong.  Try this and it should work:

JSON:

{
    "update": {
        "comment": [
            {
                "add": {
                    "body": "Comment added when transitioning issue"
                }
            }
        ]
    },
    "transition": {
        "id": "61"
    }
}
Ziyan Liu May 25, 2017

That doesn't change anything :(

Brant Schroeder
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 26, 2017

Is the comment posting if you remove the transition? 

Ziyan Liu May 26, 2017

I figured out the answer. You can only add a comment while transitioning by REST if you require a comment for transitioning in UI. Thanks for your help Brant.

Like # people like this
vigneshyadhan December 29, 2021

how can we done the same for rest/api/3?

Ankit Rastogi June 29, 2022

@Ziyan Liu  @Brant Schroeder  Can you please give me json for the transitions which can add comment. I am getting stuck on same this issue

Rafael Costa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2022

@Ziyan Liu 

{
"update": {
"comment":[{
"add": {
"body": "your comment"
}
}]
},
"transition": {
"id": "331"
}
}

but as @Ziyan Liu said, you need a screen with a comment field on the transition. to do it only create a screen empty, without fields.

Suggest an answer

Log in or Sign up to answer