Forums

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

Need to loop through subtasks of an issue using RESTAPI calls and groovy with ScriptRunner.

tomgross_com
Contributor
August 16, 2023

Trying to create some ScriptRunner groovy scripting on CLOUD to loop through the subtasks of an issue and delete some of the subtasks basked on their status. 

I found the server RESTAPI call to pull back the subtasks, but it doesn't work on CLOUD.

Server call:  /rest/api/2/issue/ISSUE-144/subtask

Am I missing something here?  Is there a new way to loop through subtasks on Cloud?

1 answer

2 votes
Helmy Ibrahim _Adaptavist_
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.
August 16, 2023

Hi Tom,

The REST API is different for Server and Cloud:

Therefore, for Cloud, you can try the following code to retrieve subtasks of an issue:

def subtasks = get('/rest/api/3/issue/ISSUE-144').asObject(Map).body.fields.subtasks

I hope this helps!

Kind regards,
Helmy

Lukasz Grobelny
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.
August 18, 2023

And from there iterate through them. If you want, I can create a simple draft of the script.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events