How to remove epic link in python? Edited

I am trying to use the Jira Python API to automatically add and remove issues. When adding, I was able to assign the epic link field (customfield_1006) to the name of an existing epic link, but when I try to remove the epic link by assigning it to an empty string, Jira throws an internal server error. I can remove the epic link through my browser, but I can't automate it through Python. Is there any way to remove an issue from an epic link using the API?

1 answer

1 accepted

I wasn't able to remove an epic link from an issue with the existing JIRA Python library. I was able to write this definition and add it to the client.py file to add this functionality.
I added this to client.py

 def remove_from_epic(self, issue_keys): 
if self._options['agile_rest_path'] != GreenHopperResource.GREENHOPPER_REST_PATH:
raise NotImplementedError('JIRA Agile Public API does not support this request')

data = {}
data['issueKeys'] = issue_keys
url = self._get_url('epics/remove', base=self.AGILE_BASE_URL)
return self._session.put(
url, data=json.dumps(data))

You can then remove the epic link from an issue in your code with the line below.  

jira=JIRA
jira.remove_from_epic(issue_keys=['<issue_key'])

 

I created a pull request to add this code to the repo so hopefully it will be integrated into a future release. 

Hi Shaun,

Thank you so much for implementing this fix! Will it be available in a library I can import soon? If I need to copy the script you wrote into my code instead, is there a library I need to import in order to make this function (besides JIRA)? 

Shaun Seaver Atlassian Team Aug 01, 2017

Sam,

 

No problem! I added the remove_from_epic definition to the client.py file for jira-python.  For me this path is 

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jira/client.py

Depending on what OS and version of Python you're using, this path may be different. As far as when it will be available I'm not sure. I submitted a pull request yesterday, and the code is still under review. You can view the progress here. I forgot to mention that this also accepts multiple issue-keys to remove the epic link from. 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

340 views 2 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you