how to set issue status in jira through java rest api

jawedshaikh January 23, 2018

I want to change/set issue status in jira through my application. How can i achieve this pls help me

1 answer

0 votes
Alexey Matveev
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.
January 23, 2018
LHC August 29, 2021

hello @Alexey Matveev ,

I can get the issue status by:
print("get_issue_status ISSUE-298 = ", jira.get_issue_status('ISSUE-298'))

get_issue_status ISSUE-298 = Waiting for Approval

 

However, I cannot set issue status with below command:

print("set_issue_status = ", jira.set_issue_status('ISSUE-298', 'Approve'))

The error was:
requests.exceptions.HTTPError: 400 Client Error: 400 for url: https://jira.company.eu/rest/api/2/issue/ISSUE-298/transitions

What was wrong with the set_issue_status command above?

The checked REST API's github site for the command definition:
def set_issue_status(self, issue_key, status_name, fields=None, update=None):
"""
Setting status by status_name. fields defaults to None for transitions without mandatory fields.
If there are mandatory fields for the transition, these can be set using a dict in 'fields'.
For updating screen properties that cannot be set/updated via the fields properties,
they can set using a dict through 'update'
Example:
jira.set_issue_status('MY-123','Resolved',{'myfield': 'myvalue'},
{"comment": [{"add": { "body": "Issue Comments"}}]})

Note that:

  • Below commands run successfully:

jira.issue_add_comment("ISSUE-298", "Add comment")

jira.get_issue_status('ISSUE-298')

jira.get_issue_status_id('ISSUE-298')

jira.get_issue_transitions('ISSUE-298')

jira.get_issue_transitions_full('ISSUE-298')

  • Below commands failed:

jira.set_issue_status('ISSUE-298', 'Approve')

jira.issue_transition('ISSUE-298', 'Approve')

jira.set_issue_status_by_transition_id('ISSUE-298', 11601)

Seems that I can only get the info from the system, and cannot set anything except adding a comment as of now. On the MS Edge, however, I have permission for this ISSUE-298 (permitted to set issue status of course).


Regards,

LHC

Suggest an answer

Log in or Sign up to answer