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

Nullpointer expection for issue object

def issueManager = ComponentAccessor.getIssueManager()
def issueId = queryParams.getFirst("issueId") as Long
def issue = issueManager.getIssueObject(issueId.toString())
log.warn(issueId)

def issueSum=issue.getSummary()

 

Hi im working on rest end point when I try to create issue object I'm getting Null pointer exception

 

error message:

{"message":"Cannot invoke method getSummary() on null object","stack-trace":"java.lang.NullPointerException: Cannot invoke method getSummary() on null object\r\n\tat Script327$_run_closure1.doCall(Script327.groovy:61)\r\n\tat com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint$_doEndpoint_closure2.doCall(UserCustomScriptEndpoint.groovy:186)\r\n\tat com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint$_doEndpoint_closure2.doCall(UserCustomScriptEndpoint.groovy)\r\n\tat com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl$_execute_closure1.doCall(DiagnosticsManagerImpl.groovy:359)\r\n\tat com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl$_execute_closure1.doCall(DiagnosticsManagerImpl.groovy)\r\n\tat com.onresolve.scriptrunner.runner.ScriptExecutionRecorder.withRecording(ScriptExecutionRecorder.groovy:13)\r\n\tat com.onresolve.scriptrunner.runner.ScriptExecutionRecorder$withRecording$0.call(Unknown Source)\r\n\tat com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl.execute(DiagnosticsManagerImpl.groovy:357)\r\n\tat com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint.doEndpoint(UserCustomScriptEndpoint.groovy:219)\r\n\tat com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint.getUserEndpoint(UserCustomScriptEndpoint.groovy:70)\r\n","status-code":"INTERNAL_SERVER_ERROR"}

1 answer

0 votes
Payne Community Leader Jul 08, 2021

Looking at the method signatures for getIssueObject() in this resource, I see that it can be passed either a Long or a String. If it's a Long, it should be the issue ID; if it's a String, it should be the issue key. It looks like you are passing the ID as a String (and hence the method looks for an issue with that key); try passing it instead as a Long, i.e.

def issue = issueManager.getIssueObject(issueId)

Suggest an answer

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

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

118 views 1 12
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