Forums

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

Unable to change status and also add comment to an Issue at the same time using rest API

anusha_s26 February 12, 2020

Hi All,

I am trying to perform a transition of an issue from one state to another. At the same time I want to add a comment. 

I checked several already asked questions: https://community.atlassian.com/t5/Jira-questions/How-to-change-the-issue-status-by-REST-API-in-JIRA/qaq-p/850658 but the solutions are not working for me.

My rest API:

def result = post("/rest/api/2/issue/${issueKey}/transitions")
.header('Content-Type', 'application/json')
.body([
    update: [
        comment: [
            add:[
                body: "added comment by script"
            ],
        ]
    ],
    transition: [
        id: 21]
])
.asString()

Error which I am facing is :

400: {"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: com.atlassian.plugin.connect.plugin.auth.scope.InputConsumingHttpServletRequest$1@7b089630; line: 1, column: 12] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"]}

1 answer

0 votes
Thomas Deiler
Community Champion
February 13, 2020

Dear @anusha_s26 ,

your top-level object (and other objects, too) is an array. This is not API compliant. It has to look like:

{
  update: {
  ...
  }
  transition: {
  ...
  }
}

Have a look at the example.

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events