The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

I am trying to delete all issues in my project

Hadas Hamerovv
Contributor
August 29, 2021

Hi guys,

Can someone help understand why the query provides null results?

 

 

def response = get('rest/api/3/issue/picker?query=project=myproject')
.header("Content-Type", "application/jason")
.asObject(Map)

response.body.issues.each { it ->

logger.info(it.key)

}

return response.body

def getIssueDetails(issue){


DeleteIssue.issue(issue.key)
}


def DeleteIssue(issueKey) {

logger.info("issues to be deleted: " + issueKey)

def resultDelete = delete('/rest/api/2/issue/'+issueKey)
.header("Content-Type", "application/jason")
.asObject(Map)

logger.info(response.body)
}

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Hana Kučerová
Community Champion
August 29, 2021

Hi @Hadas Hamerovv ,

I can see some problems like "getIssueDetails" is not called at all and "DeleteIssue" is called incorrectly. 

Please try the code below:

String jqlSearch = "project = \"myproject\""
post('/rest/api/2/search')
.header('Content-Type', 'application/json')
.body([
jql: jqlSearch,
])
.asObject(Map).body.issues.each { Map issue ->
String issueKey = issue.key
logger.warn "Issue key: ${issueKey}"
delete('/rest/api/2/issue/' + issueKey)
.header("Content-Type", "application/json")
.asObject(Map)
}
Hadas Hamerovv
Contributor
August 30, 2021

Brilliant. Thank you Hana

Like Hana Kučerová likes this