Troubleshooting REST Endpoints
Delete a REST endpoint that had broken the REST endpoints page
Problem
You have created a REST endpoint that had some code in it which caused the REST endpoints page to fail to load.
Proceed with the following solution to delete REST endpoint that caused the issue.
Solution
- Run the following script from the script console to get the REST endpoint data.
You need this data so you can find the ID of the endpoint. If it does not work please contact support and we can troubleshoot further:
Get REST endpoints from the script console
12345678910import com.onresolve.scriptrunner.runner.ScriptRunnerImpl import com.onresolve.scriptrunner.runner.RestEndpointManager import com.fasterxml.jackson.databind.ObjectMapper def restEndpointManager = ScriptRunnerImpl.scriptRunner.getBean(RestEndpointManager) def objectMapper = new ObjectMapper() def result = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(restEndpointManager.load()) "<pre>$result</pre>"The following example output is for two REST endpoints:
Warning: Make a copy of this output in case you delete the wrong REST endpoint.JSON output example12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849[ { "id" : "99048e03-21b8-4109-bbe9-94fc9324592b", "version" : 1, "ownedBy" : null, "disabled" : false, "FIELD_SCRIPT_FILE_OR_SCRIPT" : { "script" : "import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate doItAgain(httpMethod: \"GET\", groups: [\"jira-administrators\"]) { MultivaluedMap queryParams, String body -> return Response.ok(new JsonBuilder([abc: 42]).toString()).build(); } ", "scriptPath" : null, "parameters" : { } }, "FIELD_NOTES" : "another end point", "canned-script" : "com.onresolve.scriptrunner.canned.common.rest.CustomRestEndpoint" }, { "id" : "0e479c4c-be29-41a9-aeb5-ed84a94a8706", "version" : 1, "ownedBy" : null, "disabled" : false, "FIELD_SCRIPT_FILE_OR_SCRIPT" : { "script" : "import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate doThisThing(httpMethod: \"GET\", groups: [\"jira-administrators\"]) { MultivaluedMap queryParams, String body -> return Response.ok(new JsonBuilder([total: 87845485]).toString()).build(); } ", "scriptPath" : null, "parameters" : { } }, "FIELD_NOTES" : null, "canned-script" : "com.onresolve.scriptrunner.canned.common.rest.CustomRestEndpoint" } ]Each REST endpoint has a
"FIELD_SCRIPT_FILE_OR_SCRIPT"section, and in this section there is a"script"section which contains your REST endpoint's inline code. - 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 the first REST endpoint. You can use this ID to delete the problem REST endpoint. - Open your terminal or application that lets you run CURL requests.
- Run this command to delete the problem endpoint:Note: Replace the <AdminUser>, <AdminPassword> and <ID_OF_YOUR_ENDPOINT> with the values specific to your environment.1
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 successfully deleted the endpoint, it should not show anymore, and the first script should also not return any information on the deleted endpoint.