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>'@jsonfile.json
jsonfile content:{ "fields": { "parent": { "key": "<issue_key>", "id": "<issue_id>" } }}
I got HTTP response code 405
Thanks,
Yakir Giladi
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:
https://community.atlassian.com/t5/Answers-Developer-Questions/REST-API-move-sub-task/qaq-p/510350
https://community.atlassian.com/t5/Answers-Developer-Questions/Can-I-change-sub-task-parent-using-REST/qaq-p/466646
I added a ticket that is specific to sub-tasks:
https://jira.atlassian.com/browse/JRASERVER-68763
Does the latest API allow the parent of sub-task to be changed?
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.
Andy
If you have ScriptRunner you can change the parent like this:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.user.ApplicationUserimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.component.pico.ComponentManagerApplicationUser 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 =(
Hi @scott_boisvert !
Is this solution could be performed by using REST API?
With kind regardsViacheslav
@IT Accounts You can update the script to add an entry to the history log if you want.
@Slava Starovoitov I do not believe there is a built in API call from Atlassian. However, using ScriptRunner you could create a REST EndPoint that uses this script, and then yes, you could do this with REST API.
@Andy Heinzer It's been almost 4 years now and still, this API is not available in the server version. An API was created for the Cloud Version of the JIRA last year but no love for JRASERVER-68763. It has gathered enough interest. Can this be picked up now, please?
It looks like you're new here. Sign in or register to get started.