I'm trying to create a REST Endpoint to allow pulling a list of issues. In this example - Epics in a given project that are not Done. When I try to call the endpoint, I get the following error:
{"message":null,"stack-trace":"java.lang.StackOverflowError\n","status-code":"INTERNAL_SERVER_ERROR"}
This is a simplified example, my actual script is doing more, but this is isolated to the problem area.
Anyone able to do this?
Here is my REST Endpoint code:
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonOutput
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.PermissionManager
import com.atlassian.jira.permission.ProjectPermissions
import com.atlassian.jira.project.Project
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchException
import com.atlassian.jira.web.bean.PagerFilter
@BaseScript CustomEndpointDelegate delegate
getEpicsInProject(httpMethod: "GET") { MultivaluedMap queryParams ->
def projectKey = queryParams.getFirst("project") as String
def retHash = [:]
def projectList = []
def errorList = []
def resultstatus = 1
def projData
if(projectKey == null){
resultstatus = 0
errorList.push('Invalid Project')
retHash["errors"] = errorList
}else{
def jqlSearch = "type = Epic and project = " + projectKey + " and status != Done"
ApplicationUser adminUser = ComponentAccessor.getUserManager()getUserByName("admin")
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(adminUser)
def searchService = ComponentAccessor.getComponentOfType(SearchService.class)
SearchService.ParseResult parseResult = searchService.parseQuery(adminUser, jqlSearch)
def results = searchService.search(adminUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = results.getIssues()
retHash["issues"] = issues
}
retHash["status"] = resultstatus
Response.ok(JsonOutput.toJson(retHash)).build()
}