Unable to resolve issues via Restful API

Hello all!

 

I'm having a bit of trouble resolving issues via the API, I'm using Node.js to hit the endpoint and I maybe confused about which id I should be using.   

function closeTicket(ticket) {
var closingId = "10000";
  if (typeof(ticket.key) === 'undefined') {
    return reject(ticket);
  }
  ticket.key + "/transitions/?expand=transitions.fields&transitionId=5";
  var url = "https://" + JIRA_USER + ":" + JIRA_PASS + "@dbisoftware.atlassian.net:443/rest/api/2/issue/" + ticket.key + "/transitions";
  return new Promise((resolve, reject) => {
    request({
      url : url,
      body: JSON.stringify({
        "update": {
          "comment": [
            {
              "add": {
                "body": "Bug has been fixed."
              }
           }
        ]
      },
      "fields": {
        "resolution": {
          "name": "Done"
        }
     },
     "transition": {
        "id": closingId
      }
    })

   }, (err, res, body) => {

      if (err) return reject(err);
      ticket._toJira = body;

      console.log(body);
      console.log(ticket);
      return resolve(ticket);
    })
  });
}

 

The following is the response I get back from endpoint

{
"expand": "transitions",
"transitions": [
{
"id": "11",
"name": "Start Progress",
"to": {
"self": "https://dbisoftware.atlassian.net/rest/api/2/status/10407",
"description": "Assignee is currently actively working on issue.",
"iconUrl": "https://dbisoftware.atlassian.net/images/icons/statuses/generic.png",
"name": "In Progress",
"id": "10407",
"statusCategory": {
"self": "https://dbisoftware.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
}
},
{
"id": "21",   // Should I be using this ID?
"name": "Done",
"to": {
"self": "https://dbisoftware.atlassian.net/rest/api/2/status/10000",
"description": "",
"iconUrl": "https://dbisoftware.atlassian.net/images/icons/statuses/closed.png",
"name": "Done",
"id": "10000",  // Or should I be using this ID?
"statusCategory": {
"self": "https://dbisoftware.atlassian.net/rest/api/2/statuscategory/3",
"id": 3,   // OR maybe this ID?
"key": "done",
"colorName": "green",
"name": "Done"
}
}
}
]
}

 

I've tried all 3 ids listed in the response above but when I visit the ticket the status of the ticket remains unchanged.   

 

Any help would be greatly appreciated!

 

1 answer

1 accepted

This widget could not be displayed.

I've solved by using the following

 

  1. the issue the ID to be used is the top level id (in my case 21)
  2. The end  point should be /rest/api/2/issue/" + ticket.key + "/transitions/?expand=transitions.fields
  3. Method should be 'POST' (d'oh)

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

137 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you