Hi Team,
So far I have been able to raise a Jira Ticket through Python using Jira REST API's. I am also able to add comments to an already existing ticket through Python. Now i need to change status of a ticket from Open to Under Review through API's.
After seeing a couple of similar questions on the forum, I made a get request to the link below to find out the transition ID's.
jira_url = "https://<project_name>.atlassian.net/rest/api/3/issue/<issueKey>/transitions?expand=transitions.fields"
JSON Response Snippet:
{'expand': 'transitions', 'transitions': [{'id': '131', 'name': 'Under review', 'to': {'self': 'https://<project-name>.atlassian.net/rest/api/3/status/10036', 'description': '', 'iconUrl': 'https://<project-name>.atlassian.net/', 'name': 'Under review', 'id': '10036', 'statusCategory': {'self': 'https://<project-name>.atlassian.net/rest/api/3/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'hasScreen': False, 'isGlobal': True, 'isInitial': False, 'isAvailable': True, 'isConditional': False, 'fields': {}}]}
I have two questions:
1. We don't have any workflow defined. Is it necessary to have a workflow defined to be able to change the status of a ticket ?
2. If Transition ID's are to be used for changing the status of the ticket. I tried the below JSON payload to change the status of the ticket
{
"update": {
"comment": [
{
"add": {
"body": "Under Review"
}
}
]
},
"fields": {
"resolution": {
"name": "Duplicate"
}
},
"transition": {
"id": "10036"
}
}
But it didn't work and gave the response as
<Response [400]>
{'errorMessages': ["Transition id '10036' is not valid for this issue."], 'errors': {'worklog': "Field 'worklog' cannot be set. It is not on the appropriate screen, or unknown."}}
Am I using the right transition ID?
Please help us with this issue.
Thanks in advance!!
Hi Jovna,
I can see that you are looking to change an issue status using the REST API. In Jira, in order to do this, we cannot simply edit the issue to change the status field. Instead we need to execute an existing transition in this workflow.
I believe your json payload is very close, however the transition id is not 10036. That '10036' is the id number of the status. You actually have to use the id of '131'. The confusing part here is that frequently status and transition name have the same values. That is the case here where both transition and status are called 'Under review' here. That is not always the case with Jira as transitions can have any name.
Try again with the
"transition": {
"id": "131"
}
instead and see if you get a different response back from REST.
I hope this helps.
Andy
Thank you Andy. This worked for us!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Supriya Prasad _IN_ @Andy Heinzer
Hey, were you able to get your comments updated & fields? I am getting bad request error
MyJson
{"update":{"comment":[{"add":{"body":"Rocket Science"}}]},"transition":{"id":"1"}}
Transition is working fine... for me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @S
Not all transitions will have a comment field appearing as an option. I would first want to make sure that your transition in question is using a transition screen. Outside of using the REST API, if you make this transition in the Jira web UI, is there a screen that appears with a comment field on it?
If not, then you need to follow steps such as Map a screen to a workflow transition in Jira server before you can expect to add a comment during a transition be that in the Web UI or via the REST API.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.