Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Change the workflow of an issue using jira-python.

Venkat
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 3, 2019

I am trying to change the workflow of an issue in jira programmatically. Is there anyway to change the workflow of an issue using jira-python?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Warren
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.
July 4, 2019

Hi @Venkat 

You would use this API call

/rest/api/3/issue/key/transitions?expand=transitions.fields&transitionId=141

where key is the Jira key (e.g. ABC-123) and 141 needs to be the transitionId of your instance for the status you're changing to.

You would POST this with a JSON that looks something like 

{
"update": {},
"transition": {
"id": "141"
}
}

If you need to include resolving the ticket as well, then the JSON would be

{
"update": {},
"transition": {
"id": "241"
},
"fields": {
"resolution": {
"name": "Done"
}
}
}

again replacing 241 with your transitionId

0 votes
Nir Haimov
Community Champion
July 4, 2019
Venkat
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 4, 2019

We are using python script instead of API. Below is my python code.

options = {'server':'https://xxxx.atlassian.net'}

jira = JIRA(options,basic_auth=('xxx@xxxxx.com', 'xxxxxxx'))

issues = jira.search_issues('project=xxx')

print(issues)issue = jira.issue('xxx-32')
jira.transition_issue(issue, transition = 'In BB')

issue.update(summary= 'new summary', description= 'A new summary was added', issuetype ={'name': 'Change Release'})

 

By using issue.update I can update the issue type. But I cant update the workflow. Both the issues are in same project. How can update the workflow using python code instead API

Nic Brough -Adaptavist-
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.
July 6, 2019

You say "We are using python script instead of API." - that is nonsense.  There are only two ways to do what you are trying to do - in the UI or over the REST API.

So what you mean is "We are using a python script to call the API".

You will need to amend the python script so that it sends valid JSON to the API.  I don't know python in that area, but Warren and Nir have given you what you need to build to send over, and I know python can make REST calls.

TAGS
AUG Leaders

Atlassian Community Events