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

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

Suggest an answer

Log in or Sign up to answer