Rest EndPoint - IssueManager not working, returning NULL or a bunch of errors

Hello Community,

I am having a weird issue with Jira Rest Endpoints.

I want to grab an issue from Jira via Rest Endpoint utilizing IssueManager Object.

I have done this in Behaviours and in Custom Listeners and I never had a problem retrieving the issue by its key or id. 

When I try the same code in Rest EndPoint I am returned null or a bunch of errors, such as:

Script endpoint failed on method: GET myEndPoint



Below is my code:

import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import com.atlassian.jira.user.util.UserManager


import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.CustomFieldManager;

@BaseScript CustomEndpointDelegate delegate
myEndPoint(httpMethod: "GET") { MultivaluedMap queryParams, String body ->

def issueKey = "HTP-366"
def issueManager = ComponentAccessor.getIssueManager()

//Grab issue we are modifying/transitioning
MutableIssue story = issueManager.getIssueObject("HTP-366");
return Response.ok(new JsonBuilder([storyd: issueManager.getIssueCount(), story: results]).toString()).build();

From my understanding of IssueManager and ComponentManager, this is how one grabs Issues.

The weird thing is that I can grab IssueManager and I cant utilize all of its functions such as .getIssueCount() and it returns me the correct number. But when I add the key of an issue that exists in my Jira such as HTP-366, I either get "null" or the errors shown above. Also, I can use UserManager to grab any user by their respective userKey and it returns me the User Object.

Furthermore, I found a similar question to mine in the community but it was never truly solved:

I appreciate any help on this!


1 answer

Hi Roberto,

Can I ask you, if you want to get just the issue, why you do not use the Jira Rest API and instead you are trying to reinvent the wheel ?

Maybe if you could give a use case ?

Regards, Thanos

@Thanos Batagiannis [Adaptavist],

That was probably a bad example.

So thats part 1 of the EndPoint, it has about 80 more lines of code.

The rest of the code works fine so I decided to take it out of question to avoid any unnecessary confusion.

What I am doing is I am getting issueKey as an extra path in EndPoint URL. I send that to IssueManager, get the issue this EndPoint is referencing and after that I use that Issue Object to do some computation based on certain conditions.

For somereason the IssueManager part isnt working, as I mentioned above. I get NULL and I saw someone elses post that had run into this issue before.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

919 views 3 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you