The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to reject issue based on issue id using REST API/Jira Python?

kumar
August 12, 2024

Hi all,

 

I am trying to change the status of Jira issue using it's ID.

 

Below is the code snippet, I am using-. Unfortunately, it is not working. 

 
for issue_id in issue_ids:

    JIRA().transition_issue(issue=issue_id, transition='Rejected')

Can anyone help me with this?

Thanks in advance

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Vijay Dadi
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 Champions.
September 3, 2024

The transitions will not work when there are approvals attached to any status.

 

First do REST api call to get the approval ID using the below endpoint with GET method.

https://<CUSTOMER>.atlassian.net/rest/servicedeskapi/request/{{issue.key}}/approval

approval id from the response and store it in a variable {{approvalid}}

 

Now do an approval call to a below endpoint with POST method to approve the request

https://<CUSTOMER>.atlassian.net/rest/servicedeskapi/request/{{issue.key}}/approval/{{approvalid}}

 

with the body as 

 

{
      "decision":"approve"
}
This is a working automation which I am using, let me know if it works.

 

 

0 votes
Trudy P Claspill
Community Champion
August 12, 2024

Hello @kumar 

What is the result of trying to execute that code? Do you get an error?

Based on the example provided here:

https://jira.readthedocs.io/examples.html#transitions

...you should not be including issue= and transition= in the parameters. The parameters should be just the actual values.

kumar
August 13, 2024

Hi @Trudy P Claspill 

 

Thank you for your response.

 

Unfortunately, I can not use Jira Python library. Therefore, I have written REST API based script. please check below. But still it is not working. Am I missing something here?

 

url = "<domain-name.atlassian.net/rest/api/2/issue/{id}/transitions?expand=transitions.fields"

headers = {

  "Accept": "application/json"

}

for issue_id in issue_ids:

    response = requests.request(

   "POST",

   url.format(id=issue_id),

   data={

        "update": {

        "comment": [

            {

                "add": {

                    "body": "Issue is rejected."

                }

            }

        ]

    },

   "transition": {

     "id": "161"

   }

  },

   headers=headers,

   auth=auth

   )
The above script is not working. 
Can you help me with this please?
Thanks in advance

 

 

 

 

 

 

 

 

 

Trudy P Claspill
Community Champion
August 13, 2024

What is the result of trying to execute that code? Do you get an error?

In the first line are you replacing <domain-name.atlassian.net with the actual base URL for you site?

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events