Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can you close a ticket using the API?

djlabowski September 27, 2011

Hello all. I am new to Jira. I have a client who uses Jira. They would like their CMS to close a ticket when the CMS publishes a particular peice of content. At a high level what I'm thinking is that in the CMS they will input the id of the Jira ticket and then on the published event I will programmatically close the ticket.

My question is A) is this possible? B) Can you direct me to the correct API's and code examples???

Thank you very much!

5 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Wojciech Seliga
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.
September 27, 2011

You can also close issues using JIRA REST API - http://docs.atlassian.com/jira/REST/latest/#id2474418

Transitioning issues via REST is support IIRC since 4.2.

And definitely REST is the way to go for the future. SOAP won't be enhanced in the future versions of JIRA, the focus is put entirely on REST.

REST tutorial is located here.

You may also consider using JIRA REST Java client (if you CMS uses or can easily use Java).

1 vote
Ivar
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.
September 27, 2011

This is possible; have a look at this page:

http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client#CreatingaSOAPClient-SampleJavaSOAPclient, choose your version and create the sample code. Read the corresponding documentation here: http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html?com/atlassian/jira/rpc/soap/JiraSoapService.html.

Code in c# below. Btw - you might want to check if the user you use have rights, etc., before closing an issue. My code assume that the user you authenticate with have necessary rights.

public void CloseJiraIssue()
{
     string token = string.Empty;
     var JiraService = new JiraWebService.JiraSoapServiceService();
     try
     {
          token = JiraService.login("user", "pass");
          JiraWebService.RemoteFieldValue status = new JiraWebService.RemoteFieldValue();
          // The status field you want to update
          status.id = "status";
          status.values = new string[] { "6" }; // Set it to closed status
          // Be aware - "2" is the Close issue transition in your projects workflow
           JiraWebService.RemoteIssue issue = JiraService.progressWorkflowAction(token, "PLAYGROUND-42", "2", new JiraWebService.RemoteFieldValue[]{status});           
     }
     catch{}
     finally
     {
          JiraService.logout(token);
          JiraService.Dispose();
     }
}
0 votes
djlabowski October 16, 2011

Ivar - My apologies for the delay. This is a bit of a lengthy process for testing etc. BUT I REALLY appreciate your feedback and level of detail. I will be testing out in the next month or two and will let you know what I find.

Thanks!

0 votes
Ivar
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.
October 4, 2011

It would be nice if you accepted one of the answers :)

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
September 27, 2011

JIRA Command Line Interface progressIssue action.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events