Delete Broken Scriptrunner Server Rest Endpoints


You may have created a Rest Endpoint that had some code in it which then caused the rest endpoints page to fail to load.

We are working on handling this better. However, we understand that you may know which rest endpoint caused the problem and you just want to delete that rest endpoint so you can get back into the rest endpoints administration page.

Note: For support to tell you why the failure happened in the first place we would like you to send us the script that causes the problem so we can reproduce the issue.


Step 1: Get your rest endpoints data

First, we need to find the ID of the broken Endpoint. (I am assuming you will know the fragment that broke it by referring to the fragments script content. If you do not then please contact support.)

Run this script from the script console. (If it does not work please contact support and we can troubleshoot further):

Get Rest Endpoints

Get Rest Endpoints From The Script Console
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.RestEndpointManager
import com.onresolve.scriptrunner.canned.ConfiguredObjectMapper
def restEndpointManager = ScriptRunnerImpl.scriptRunner.getBean(RestEndpointManager)
def objectMapper = ScriptRunnerImpl.scriptRunner.getBean(ConfiguredObjectMapper).get()
def result = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(restEndpointManager.load())

Step 2: Find the broken endpoint by ID

Now we need to identify the ID of the broken script from the output

This is an example output for 2 rest endpoints:

JSON Result

JSON Output Example
[ {
  "id" : "99048e03-21b8-4109-bbe9-94fc9324592b",
  "version" : 1,
  "ownedBy" : null,
  "disabled" : false,
    "script" : "import\nimport groovy.json.JsonBuilder\nimport groovy.transform.BaseScript\n\nimport\nimport\n\n@BaseScript CustomEndpointDelegate delegate\n\ndoItAgain(httpMethod: \"GET\", groups: [\"jira-administrators\"]) { MultivaluedMap queryParams, String body ->\n    return Response.ok(new JsonBuilder([abc: 42]).toString()).build();\n}\n",
    "scriptPath" : null,
    "parameters" : { }
  "FIELD_NOTES" : "another end point",
  "canned-script" : ""
}, {
  "id" : "0e479c4c-be29-41a9-aeb5-ed84a94a8706",
  "version" : 1,
  "ownedBy" : null,
  "disabled" : false,
    "script" : "import\nimport groovy.json.JsonBuilder\nimport groovy.transform.BaseScript\n\nimport\nimport\n\n@BaseScript CustomEndpointDelegate delegate\n\ndoThisThing(httpMethod: \"GET\", groups: [\"jira-administrators\"]) { MultivaluedMap queryParams, String body ->\n    return Response.ok(new JsonBuilder([total: 87845485]).toString()).build();\n}\n",
    "scriptPath" : null,
    "parameters" : { }
  "FIELD_NOTES" : null,
  "canned-script" : ""
} ]

(Keep a copy of your version of the above in case you delete the wrong one)

Each rest endpoint will have a "FIELD_SCRIPT_FILE_OR_SCRIPT" section and in this section, there will be a "script" section which contains your rest endpoints inline code if you are using inline code. You will need to review the "script" section to find the broken rest endpoint.

Once you have found the broken endpoint, look for the "id" element above the "FIELD_SCRIPT_FILE_OR_SCRIPT" section. For example, in the above output, the id "99048e03-21b8-4109-bbe9-94fc9324592b" is for my first rest endpoint that outputs  abc:42

I am going to delete my endpoint with the ID "99048e03-21b8-4109-bbe9-94fc9324592b" 

Step 3: Deleting the Rest Endpoint

Open your terminal or application that lets you run CURL requests.

Run this command to delete the problem endpoint (replace the <AdminUser>, <AdminPassword> and <ID_OF_YOUR_ENDPOINT> with the values specific to your environment):

Example CURL Command Template
curl -X DELETE -u <AdminUser>:<AdminPassword> <BASE_URL>/rest/scriptrunner/latest/custom/customadmin/<ID OF YOUR ENDPOINT>

After running the above go back to your Jira user interface, clear the browser cache and then reload the Rest Endpoints page.

If you deleted the endpoint it should not show anymore and the first script should also not return any information on the deleted endpoint.