Atlassian .Net SDK modifying status and resolution

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 vote
Warren Levy Community Champion Jul 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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

140 views 0 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