You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Get Email Address of Approvers


When the details of the approvers of an issue on a Service Desk are required, a REST Endpoint request is made to retrieve the details.


In this example, only the email addresses of the approvers who have not yet approved the ticket are included. The information from this REST Endpoint is invoked by the Scheduled Job and triggers the reminder email.

Good to Know

  • When invoking the REST Endpoint, ensure the issue key is included. For example: http://<JIRA base URL>/rest/scriptrunner/latest/custom/getApprovers?issueKey=<IssueKey>
  • If the issue key is not included when the REST Endpoint is invoked, a runtime exception will be returned. For example: http://<JIRA base URL>/rest/scriptrunner/latest/custom/getApprovers
  • The service project request type (for example, Report a Bug) has to be selected for the ticket to be accessible.


  • Jira Service Desk Jira Service Desk (8.0 - 8.17)
  • ScriptRunner for Jira ScriptRunner for Jira (6.30.0)
import import com.atlassian.jira.component.ComponentAccessor import groovy.json.JsonBuilder import groovy.json.JsonSlurper import groovy.transform.BaseScript import import javax.servlet.http.HttpServletRequest import import @BaseScript CustomEndpointDelegate delegate getApprovers { MultivaluedMap queryParams, body, HttpServletRequest request -> def issueKey = queryParams.getFirst('issueKey') def applicationProperties = ComponentAccessor.applicationProperties final def baseUrl = applicationProperties.getString('jira.baseurl') final def username = 'admin' final def password = 'q' final def headers = ['Authorization': "Basic ${"${username}:${password}".bytes.encodeBase64()}", 'X-ExperimentalApi': 'opt-in', 'Accept': 'application/json'] as Map def http = new RESTClient(baseUrl) http.setHeaders(headers) def resp = http.get(path: "/rest/servicedeskapi/request/${issueKey}/approval") if (resp.status != 200) { log.warn 'Commander did not respond with 200 for retrieving project list' } def issueJson = as Map def approvers = [] as List def result = [] as List def filteredMap = issueJson.get('values')[0].findAll { it.key == 'approvers' } approvers.addAll(filteredMap*.value) def json = new JsonSlurper().parseText(new JsonBuilder(approvers[0]).toPrettyString()) json.findAll { it.approverDecision == 'pending' }.findAll { result.add(it.approver.emailAddress) } Response.ok(new JsonBuilder(result).toPrettyString()).build() }
Discovered an issue? Report it here