The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

doTransition returns 400 error except when transitioning to 'Done'

Deleted user
August 13, 2018

I am trying to use the JIRA API to allow users to change the status of bugs from my site. I am using a node.js interface to interact with the API. Depending on the current status of the bug, and the desired status, I update the body of the POST with the appropriate status ID and resolution name. Only transitions to 'Done' is are working right now. All other transitions return a 400 HTTP error. I've noticed that I give 'Done' bugs a resolution name of 'Fixed' while my other transitions ('Open' and 'In Progress') have a resolution name of 'Unresolved'. When I remove the resolution name of 'Done' transitions, I also get a 400 error. Could my issues arise from an incorrect resolution name? Here is the code I'm using:

var issueTransition = {
fields: {
resolution: {
name: null
}
},
transition: {
id: null
}
};

if(newStatus === currentStatus){
logger.error("Same Status")
res.send(400);
}
else{
switch (currentStatus) {
case "Open":
switch (newStatus) {
case "Done":
issueTransition.fields.resolution.name = "Fixed";
issueTransition.transition.id = 21;
break;
case "In Progress":
//issueTransition.fields.resolution.name = "Unresolved";
issueTransition.transition.id = 11;
break;
}
break;
case "Done":
switch (newStatus) {
case "Open":
//issueTransition.fields.resolution.name = "Unresolved";
issueTransition.transition.id = 51;
break;
case "In Progress":
//issueTransition.fields.resolution.name = "Unresolved";
issueTransition.transition.id = 61;
break;
}
break;
case "In Progress":
switch (newStatus) {
case "Done":
issueTransition.fields.resolution.name = "Fixed";
issueTransition.transition.id = 41;
break;
case "Open":
//issueTransition.fields.resolution.name = "Unresolved";
issueTransition.transition.id = 31;
break;
}
break;
}


//Use this to figure out the unique transition Id
jiraUser.listTransitions(key, function(error, response) {
if(error) {
logger.error("Error getting transitions:", error);
//res.send(500, "Error getting transitions");
} else {
logger.info("Successfully got transitions" + JSON.stringify(response));
//res.send(200, response);
}
});


jiraUser.transitionIssue(key, issueTransition, function(error, response) {
if(error) {
logger.error("Error updating status:", error);
res.send(500, "Error updating issue status");
} else {
logger.info("Successfully updated the status to " + newStatus);
res.send(200);
}
});
}

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Deleted user
August 13, 2018

It turns out only transitions to 'Done' can specify a resolution. Since I was setting the name to `null` before my switch, my object was invalid.

TAGS
AUG Leaders

Atlassian Community Events