Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

add a comment while changing issue status by REST

Ziyan Liu
Contributor
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

1 accepted

0 votes
Answer accepted
Brant Schroeder
Community Champion
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
Contributor
May 25, 2017

That doesn't change anything :(

Brant Schroeder
Community Champion
May 26, 2017

Is the comment posting if you remove the transition? 

Ziyan Liu
Contributor
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
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!
December 29, 2021

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

Ankit Rastogi
Contributor
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