Hi Im working with Script fragments and rest endpoints to run a script. What I need is to access the issue properties so that I could display the Issue details when I click the web Item.
Basically I need to know how to access issue object in a rest endpoint
Thanks
You must transmit the issue that you want to work with via the http request and your endpoint must be ready to accept this information in one of 2 or 3 ways (there may be others).
If your Endpoint is a GET, then you can pass the issue via the request query parameter or request path. If it's a PUT or POST, then it could be either in the request query parameter, request path or payload data.
For example, if you call the rest endpoint from an issue context in a web item fragment, you can make the URL something like this:
/rest/scriptrunner/latest/custom/yourEndPoint?issueKey=${issue.key}
Then in your rest Endpoint:
yourEndPoint(httpMethp:'GET', groups:['jira-users']){MultivaluedMap queryParams ->
def issueKey = queryParams.getFirst('issueKey')
if(!issueKey){
return Response.serverError().entity([error:'You must specify issueKey in request query parameter']).build()
}
def issue= ComponentAccessor.issueManager.getIssueObject(issueKey)
/* do stuff with issue object */
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.