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
I got HTTP response code 405
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 https://jira.atlassian.com/browse/JRASERVER-61359
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:
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.
If you have ScriptRunner you can change the parent like this:
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)
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