Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Hi how can I access the current issue properties in Rest end points

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

1 answer

0 votes

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 */
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

701 views 2 21
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you