Forums

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

Scriptrunner list of Custom REST endpoints with URL

Daniel Garcia
Contributor
February 18, 2018

I'm writing a script that returns a list of custom endpoints. I'm retrieving the list of endpoints with the following code

import com.onresolve.scriptrunner.runner.RestEndpointManager
import com.onresolve.scriptrunner.runner.util.OSPropertyPersister

List<Map> restEndpoints = OSPropertyPersister.loadList(RestEndpointManager.CONFIG_REST)

How would I find out what the rest URL is for each endpoint?

1 answer

1 accepted

1 vote
Answer accepted
Daniel Garcia
Contributor
February 20, 2018

I've finally got this working.....

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.RestEndpointManager
import com.onresolve.scriptrunner.runner.util.OSPropertyPersister
import com.atlassian.plugin.ModuleDescriptor
import com.atlassian.plugin.Plugin
import com.atlassian.plugin.PluginAccessor


PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor()
Plugin sr = pluginAccessor.getPlugin('com.onresolve.jira.groovy.groovyrunner')
ModuleDescriptor mdREM = sr.getModuleDescriptor('restEndpointManager')
RestEndpointManager restEndpointManager = (RestEndpointManager)mdREM.getModule()
List<Map> restEndpoints = OSPropertyPersister.loadList(RestEndpointManager.CONFIG_REST)
List<Map> endpoints = restEndpointManager.getEndpointsForDisplay(restEndpoints)

This gives me an endpoint list with each entry looking like this

{
    "FIELD_NOTES": "contents of notes",
    "FIELD_INLINE_SCRIPT": "// Source code here",
    "FIELD_SCRIPT_FILE": "",
    "canned-script": "com.onresolve.scriptrunner.canned.common.rest.CustomRestEndpoint",
    "endpoints": [
        {
            "verb": "GET",
            "name": "script_name",
            "groups": [
                "group 1",
                "group 2"
            ],
            "resourcePath": "Script99.groovy"
        }
    ],
    "id": "999999999",
    "resourcePath": "Inline script"
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events