Atlassian .Net SDK modifying status and resolution

sean o'brien July 18, 2017

I have a very simply console app which I'm using to wrap my head around the JIRA .Net SDK. Most of it is quite straight forward to use but my main thing is being able to change the status and priority of issues programmatically. 

I have the following code inside my main method:

 var issues = from i in jira.Issues.Queryable
where i.Summary == "Issue 2" && i.Assignee == "admin"
orderby i.Created
select i;


foreach (var issue in issues)
{
Console.WriteLine(issue.Summary);

Console.WriteLine(issue.Resolution);
Console.WriteLine(issue.Status);
issue.Priority = IssuePriority.lowest.ToString();
//issue.Resolution = "10000";
//issue.Resolution = "10003";// ResolutionStatus.done.ToString();
issue.SaveChanges();

}

 This code happily brings back my issue and I can change the summary, priority and all the other bits via code just fine. However, when I try and use the Resolution and Status options, I get errors. 

I created 2 enums that hold the expect values inside them:

 public enum IssuePriority
{
highest = 1,
high = 2,
medium = 3,
low = 4,
lowest = 5
}

public enum ResolutionStatus
{
done = 10000,
wontDo = 10001,
duplicate = 10002,
cannotReproduce = 1003
}

But when I try and change the resolution, I get the following error:

"Response Content: {\"errorMessages\":[],\"errors\":{\"resolution\":\"Field 'resolution' cannot be set.
It is not on the appropriate screen, or unknown.\ 

Looking at the description of resolution is has a getter and setter, but still the issue persists. Have anyone combatted this error before? 

1 answer

0 votes
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2017

Hi Sean

Using the code I suggested in your earlier question, I transition an issue to the Resolved status with

RunQuery(

"https://berkeleygroup.atlassian.net/rest/api/2/issue/{JiraKey}/transitions?expand=transitions.fields&transitionId=241",

null,

"{\"update\":{},\"transition\":{\"id\":\"241\"},\"fields\":{\"resolution\":{\"name\":\"Done\"}}}",

"POST")

The first parameter passes the issue id in as {JiraKey}

The third parameter is a Json packet, where transition specifies what status to change to (depending on your workflow) and resolution is the resolutionstatus that you were trying to set

The fourth parameter is now not GET but POST

 

Then I close it with

RunQuery(

"https://berkeleygroup.atlassian.net/rest/api/2/issue/{JiraKey}/transitions?expand=transitions.fields&transitionId=141",

null,

"{\"update\":{},\"transition\":{\"id\":\"141\"}}",

"POST")

Let me know if you have any further questions about this

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2017

There's a couple of underlying principles in this that Warren handles perfectly and automatically but doesn't explicitly mention

1.  REST respects your setup.  You need the Resolution to be on the screen so you can set it.  An additional wrinkle to that is that any competent JIRA admin will *never* put the Resolution on anything other than a "transtion" or "view" screen.

2.  You cannot "set" status (it only works when importing issues, not "edit" or "update").  You must transition from one status to another.

Suggest an answer

Log in or Sign up to answer