It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can I change the parent field of sub-task in Jira via REST API ?

Can I change the parent field of sub-task in Jira via REST API ?
I tried the command:

/usr/bin/curl -u admin:zubur1 -X POST -H Content-Type:application/json 'http://<my-jira>:<port>/rest/api/2/issue/<issue_key>' --data @@@jsonfile.json

jsonfile content:
              "key": "<issue_key>",
              "id": "<issue_id>"

I got HTTP response code 405 



Yakir Giladi

2 answers

0 votes
Andy Heinzer Atlassian Team Mar 16, 2018

Unfortunately, not all fields of an issue can be edited in this way.  In this case, you can't just change the parent ID field for a subtask.  Even when in the web front end of Jira, you can't just edit that field on this issue.   This is because this is a system field that is specific to that issue type (subtasks are special snowflakes in this regard).   Outside the REST API, the only way to change a subtask to be under a new parent issue is to call the move function in Jira, and in turn move the issue to a new parent.  

The problem as I see it is the REST API's current inability to move issues.  There is an existing feature request for this in

Should this someday be implemented in Jira, then I would expect that you could then move subtasks via a REST call.

I have not found any other work-arounds for this problem, but you are not alone here, this question has been asked a number of times before:

I added a ticket that is specific to sub-tasks:

Does the latest API allow the parent of sub-task to be changed? 

Andy Heinzer Atlassian Team May 17, 2019

Hi @Varrun SS 

The pair of feature requests in JRASERVER-61359 and JRASERVER-68763 are still accurate.  Unfortunately, even in the current versions of Jira Server (8.1.0 today), you cannot move an issue or change a subtask's parent via the REST API.

I would recommend watching these two tickets.  Should this feature come to Jira Server, I would expect these to be updated to reflect which version of Jira would gain this feature.


0 votes

If you have ScriptRunner you can change the parent like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.pico.ComponentManager

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue childIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("DEMO-69")
Issue parentIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("DEMO-9")

ComponentAccessor.getSubTaskManager().changeParent(childIssue, parentIssue, user)

Actions of this script are not visible in the history of the issue's changes =(

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you