Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,328,696
Community Members
 
Community Events
168
Community Groups

How to update an issue status through C# code

I am trying to update status of an issue in JIRA using C# code. 

See code below:

var data = new Issue();
data.fields.project.key = "VRM";
data.fields.summary = obj.summary;
data.fields.description = obj.description;
data.fields.issuetype.name = obj.issuetype;
data.fields.status.name = obj.status;
data.fields.priority.name = obj.priority;

string postUrl = String.Format("{0}rest/api/2/issue/{1}", Url, obj.issueid);
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
client.BaseAddress = new System.Uri(postUrl);

byte[] cred = UTF8Encoding.UTF8.GetBytes("txxxxxxxx:xxxxxxxxx");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
System.Net.Http.Formatting.MediaTypeFormatter jsonFormatter = new System.Net.Http.Formatting.JsonMediaTypeFormatter();
System.Net.Http.HttpContent content = new System.Net.Http.ObjectContent<Issue>(data, jsonFormatter);
System.Net.Http.HttpResponseMessage response = client.PutAsync(postUrl, content).Result;
if (response.IsSuccessStatusCode)
{
result = true;
// result = response.Content.ReadAsStringAsync().Result;

}

2 comments

i am not able to update issue using above code plz help me asap.

Comment

Log in or Sign up to comment