What is the correct format for jira transition object while using in rest API ?

Rahim T_S
Contributor
February 1, 2023

I have be using https://www.npmjs.com/package/jira-client to create a JIRA utility and to update issue status via API

 

I initially listed all the transitions using 

jira

  .listTransitions(<issueId (redacted)>)

  .then((result) => {

    console.log(result);

  })

  .catch((err) => {

    console.error(err);

  });
and got
{
expand: 'transitions',
transitions: [
{ id: '4', name: 'Start Progress', to: [Object], fields: {} },
{ id: '5', name: 'Resolve Issue', to: [Object], fields: [Object] },
{ id: '2', name: 'Close Issue', to: [Object], fields: [Object] }
]
}
So to transition the issue, I used the API available

jira

  .transitionIssue("redacted issue number",{id: '5', name: 'Resolve Issue', to: [Object], fields: [Object]})

  .then((result) => {

    console.log(result);

  })

  .catch((err) => {

    console.error(err);

  });
since this API requires two input fileds, 
issueId: string, issueTransition: JiraApi.TransitionObject


but I'm getting an error saying


Can someone help me figure out what is the correct format of TransitionObject ?


Thanks

Error: {"errorMessages":["Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@2115007d; line: 1, column: 45] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"fields\"])"]}


1 answer

1 accepted

1 vote
Answer accepted
Rahim T_S
Contributor
February 1, 2023

Found the solution

jira

  .transitionIssue("<issue number>", {

    transition: {

      id: '3'

    }

  })
where 3 or any number corresponds to the available transitions for that issue

Suggest an answer

Log in or Sign up to answer