How to close jira issue using rest appi

Arun October 21, 2016

I'm unable to close kita issue. I tried with transition I'd, status id. Nothing is working. I'm using put method rest API. Some one please help me.

1 answer

1 vote
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.
October 21, 2016

We don't know what you've tried, how your system is configured or what errors you are getting.

Arun October 23, 2016

Thank you for your response. I am using PUT method and updating comments as well as state set to done. Below JSON I have tried.

{
"update": {
"comment": [
{
"add": {
"body": "comments"
}
}
]
},
"transition" : {"id":"31"}
}

Transition id for the value 'DONE' is 31.

When I run this , I am getting 201 but status not changed only comments are updated.

 

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.
October 23, 2016

So you are making two separate calls to the REST API?  One for comment and one for transition?

What happens if you put the transition first?

Arun October 23, 2016

Getting status as 204 but issue is still open, only comments are updated.

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.
October 24, 2016

Ok, what if you just try the transition alone?

You also say "transition id for done is 31" - are you sure that is the transition ID and not the status id for Done?  The id can easily vary by workflow, and 31 is used in a lot of examples, so I've got to check you're not just copying that without checking the workflow.

Arun October 24, 2016

It is correct transition id only , i verifed. I also tried with transition id alone, this time I get 400 code and in response says method failed

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.
October 24, 2016

Ok, that's better, we're getting a proper error message.  What does the rest of it say?

Arun October 24, 2016

Nothing else, just method failed with code as 400

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.
October 24, 2016

Hmm.  What type of call is it?  put/get/etc?

Suresh (Hoffensoft)
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 24, 2016

somehow the comment i entered is deleted?

Arun October 24, 2016

I am using PUT method.

Do I need to use POST method to change the status field?

Also will the transition id differ for for DONE status, in one of the issue, I am getting the transition id as 41, another issue is showing 31. Will it differ for each issue based on current status? 

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.
October 24, 2016

Yes, try post instead.

You don't normally set a JIRA issue status in most cases.  A status change is the result of a transition, so it'll be done for you when we can get this to work!

Transition IDs vary, yes.  Within a workflow, the ids will always be unique, but the transitions can be shared.  You might have "done" with an ID of 31 that is used on Open -> Done, and Dev -> Done, but then have 41 being the transition from Test -> Done.

Arun October 25, 2016

Thank you for your help. I tried POST method and I can able to close the JIRA issue.

Thank you once again.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events