Issue transition with required fields via REST

Hello,

can you please help me. I'm not able to perform a transition via REST if some fields are required.

 

http://DOMAIN/jira/rest/api/2/issue/KEY-89/transitions?expand=transitions.fields

Result:

{
"expand": "transitions",
"transitions": [
  {
"id": "21",
"name": "to IN INVESTIGATION",
"to": {
"self": "http://DOMAIN/jira/rest/api/2/status/11505",
"description": "ORDER Investigation and effort estimation started at K&A.",
"iconUrl": "http://DOMAIN/jira/images/icons/statuses/generic.png",
"name": "IN INVESTIGATION",
"id": "11505",
"statusCategory": {
"self": "http://DOMAIN/jira/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"fields": {}
},
  {
"id": "81",
"name": "to FINISHED",
"to": {
"self": "http://DOMAIN/jira/rest/api/2/status/11508",
"description": "Order realization finished.",
"iconUrl": "http://DOMAIN/jira/images/icons/statuses/generic.png",
"name": "FINISHED",
"id": "11508",
"statusCategory": {
"self": "http://DOMAIN/jira/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"fields": {
"worklog": {
"required": false,
"schema": {...},
"name": "Log Work",
"operations": [
  "add"
],
}
}
}
],
}

Now I'm trying to move Key-89 to status "FINISHED".

Jira.transition_issue(issue, tFinished, fields={'timespent' : "6m"})

Result: 

{"errorMessages":[],"errors":{"timespent":"Field 'timespent' cannot be set. It is not on the appropriate screen, or unknown."}}

Unfortunately the hint on the other question in the Forum throws this error:

{"errorMessages":[],"errors":{"worklog":"Field does not support update 'worklog'"}}

Here is how it looks like in the WebUI:

toFinished.jpg

Do you have anny suggestions? 

1 answer

This widget could not be displayed.

It appears jira python does not support worklog in transition_issue.  I modified the client.py file in the API directly and was able to get it to set the time during the transition.


- def transition_issue(self, issue, transition, fields=None, comment=None, **fieldargs):
+ def transition_issue(self, issue, transition, fields=None, comment=None, worklog=None, **fieldargs):

@@ -1242,6 +1242,8 @@ class JIRA(object):
'id': transitionId}}
if comment:
    data['update'] = {'comment': [{'add': {'body': comment}}]}
+ if worklog:
+     data['update'] = {'worklog': [{'add': {'timeSpent': worklog}}]}

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

125 views 15 7
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