Forums

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

How to remove issuelinks from the JIRA id using python jira

ssubramani_3pc
Contributor
December 22, 2021

Hi ,

 

I am using JIRA python to update to issue link(duplicate link) for JIRA id and it works fine.

Now i want to remove those issue link from that JIRA id 

 

Any Idea pls

1 answer

1 accepted

0 votes
Answer accepted
ssubramani_3pc
Contributor
December 22, 2021

I am able to do in using below code

 

#getting issue links

#create JIRA instance
self
.jira = JIRA(basic_auth=(self.jira_username, self.jira_api_token), options={"server": self.jira_server})
#Pass JIRA name and get Issue links
idl=self.jira.issue(jiraid) # passing JIRA name
getIssuelinks=idl.fields.issuelinks #issuelinks
#iterate and delete
for
x in getIssuelinks:
print(x.id)
self.jira.delete_issue_link(x.id) 
Julio Domingues
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!
September 11, 2023

Could you clarify : 

idl=self.jira.issue(jiraid) # passing JIRA name
getIssuelinks=idl.fields.issuelinks #issuelinks

Since id1 is a dictionary this does not work,
I should be doing something wrong.

My Code:
from atlassian import Jira
import json
jira = Jira(
url='https://aa.bb.com/',
token='someToken')

issueData = jira.issue("BBBB-1000")
json_formated= json.dumps(issueData, indent=1)
getIssuelinks=issueData.fields.issuelinks #issuelinks
print(json_formated)

Error:
Traceback (most recent call last):
File "C:\Data\repositories\jira_python\jira\jira_test.py", line 9, in <module>
getIssuelinks=issueData.fields.issuelinks #issuelinks
^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'fields'

Nicolas Grymonprez
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!
March 3, 2025

It's a bit late, but as the above helped me, here is my code to remove all links within an Epic. 

epicKey = input("Enter the Epic key") 
jqlStr = f'issueFunction in issuesInEpics("key = {epicKey}") OR (type = Epic AND key = {epicKey})'
fields = ['key', 'issuelinks']
issues = jira.search_issues(jql_str=jqlStr, fields=fields, maxResults=1000)

for issue in issues:
links = getattr(issue.fields, 'issuelinks', [])
for link in links:
try:
jira.delete_issue_link(str(link.id))
print(f"inwardIssue link {link.id} deleted")
except Exception as e:
print(f'Failure removing links using delete_issue_link: {e}')

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events