Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

DELETE (custom) rest endpoint- ScriptRunner

Does anybody have an example of DELETE (custom) rest endpoint for Confluence? (using ScriptRunner plag in)


1 answer

1 accepted

1 vote
Answer accepted

Hi Neta,

Below is an example of a DELETE REST Endpoint that deletes an issue and returns some Json. If you are experiencing issues when trying to use this with a web item then it will not work. You need to hit this endpoint with a DELETE http request. The options for web items does not include this. 

I have tested this using Postman and it works. You may want to use an AJAX request in a web resource in order to trigger this from an item within your instance.

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser
import groovy.json.JsonOutput
import groovy.transform.BaseScript


@BaseScript CustomEndpointDelegate delegate

deleteIssue(httpMethod: "DELETE"){ MultivaluedMap queryParams ->

def issueId = queryParams.getFirst("issueKey")

IssueManager issueManager = ComponentAccessor.getIssueManager()
IssueService issueService = ComponentAccessor.getComponent(IssueService.class)
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

Issue issue = issueId ? issueManager.getIssueObject(issueId.toString()) : null

def deleteValid = issue ? issueService.validateDelete(currentUser, : null
def deleted = deleteValid ? issueService.delete(currentUser,deleteValid,EventDispatchOption.ISSUE_DELETED, false) : null
def errors = deleted?.errors

def flag = []

flag = [
type : 'error',
title: "Error",
close: 'auto',
body : "Something went wrong"

flag = [
type : 'success',
title: "Issue Deleted",
close: 'auto',
body : "Issue Deleted"

return Response.ok(JsonOutput.toJson(flag)).build()

* Created by jhoward on 10/10/2017.


Johnson Howard (Adaptavist)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

177 views 0 4
Join discussion

Community Events

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

Events near you