Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Nullpointer expection for issue object

Pradeep A
Contributor
July 8, 2021

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 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
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events