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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,799 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot