Forums

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

How to add issue to Epic via API?

kckern April 21, 2019

From any given non-epic issue, the JIRA UI allows the user to "Add to Epic," and is presented with a drop-down containing a list of existing Epics to link to. In case one has already been chosen, the user is able to change it via a similar menu.

Screen Shot 2019-04-22 at 11.52.07 AM.pngScreen Shot 2019-04-22 at 11.57.02 AM.png

So where is this functionality in the API?

 

The closest I've been able to find is `/rest/api/2/issueLink`

https://docs.atlassian.com/software/jira/docs/api/REST/6.4.9/#d2e1577

This successfully links two issues in terms of "contains" or "blocks" or "duplicate," but does not establish it as child issue, the way linking an Epic does.  

 

Furthermore, linked issues and child issues are displayed separately on the UI:

Screen Shot 2019-04-22 at 12.04.46 PM.png

So how do I create child issues (ie link Epic to issue) via the API? 

1 answer

1 accepted

1 vote
Answer accepted
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.
April 21, 2019
kckern April 21, 2019

Thank you Alexey!  That seems to be the right place for what I am looking to do.

Looking further at the docs, i see the functions are based on two separate APIs

  • /rest/agile/1.0/
  • /rest/api/2/

Screen Shot 2019-04-22 at 2.08.58 PM.png

I'm still new to the JIRA API, and unclear on the distinction between the two.

I have no problem executing the functions on /rest/api/2/

But with /rest/agile/1.0/ (including "move issues to epic") I am getting:

"The requested epic cannot be viewed because it either does not exist or you do not have permission to view it."

I created the project, the board, the epic, so there is no reason why my access should be restricted.  It is a private project, though.  Could that be why?

Are there extra or separate authentications steps I need to take to get my token to work?  Or some admin somewhere need to grant me permissions?


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.
April 21, 2019

You should use /rest/agile/1.0/epic/{epicIdOrKey}/issue.

rest/agile/1.0 is for jira software

rest/api/2/ for jira core

Like Florian Groulez likes this
kckern April 21, 2019

OK thanks.  But, when using /rest/agile/1.0/epic/{epicIdOrKey}/issue, I am still stuck on this:

"The requested epic cannot be viewed because it either does not exist or you do not have permission to view it."

I wonder if there are project or board permissions I can tweak...

kckern April 21, 2019

FYI my project is Next-gen.  Perhaps this is a known issue?

https://jira.atlassian.com/browse/JSWCLOUD-17305

There appear to be some recent comments (last month) indicating it is still broken.

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.
April 21, 2019

That is right. Next-gen projects can not use this Rest Api. I do not know of any public Rest Api available for next-gen projects yet.

Suggest an answer

Log in or Sign up to answer