I am trying to send the accountId for the reporter field. But it says that user as null.
Asked by Rakesh:

"reporter": {"id": "712020:50163ca5-c07e-4a15-a400-14aa37f48cee"}, "priority": {"name": "Medium"} }} 2024-07-11 12:34:02 - Failed to create ticket. Status: 500. Response: {"message":"Cannot invoke \\"com.atlassian.jira.user.ApplicationUser.getUsername()\\" because \\"user\\" is null","status-code":500,"stack-trace":""}


Answers:
author: Jehan Bhathena
body: Hi [@Rakesh](/t5/user/viewprofilepage/user-id/5541290)

What API are you trying to call? And is this the complete Json body that you're passing?

From the looks of it I'd recommend checking if the user has permissions to create a ticket or can be set as the reporter, would also check if the user who is setting the User Assignee (user whose token is used) has the Assign Issue permission too

comments: author: Rakesh
body: I am using this url to fetch the user details.  
url: "<https://example.atlassian.net/rest/api/3/user/search?query=example@gmail.com>".

The user is there in the project and have the permissions that you have mentioned.

And about json, for now i hard coded the accountId for the reporter field.But i am getting this error:{"message":"Cannot invoke \\"com.atlassian.jira.user.ApplicationUser.getUsername()\\" because \\"user\\" is null","status-code":500,"stack-trace":""}  


author: Jehan Bhathena
body: Hi [@Rakesh](/t5/user/viewprofilepage/user-id/5541290)

Thanks for the info, can you mention for which API you get the 500 error? Or What's the steps that you've used to reproduce this error.


author: Rakesh
body: [@Jehan Bhathena](/t5/user/viewprofilepage/user-id/5119409)

I am using this url for fetching the user details,

[https://example.atlassian.net/rest/api/3/user/search?query=example@gmail.com](https://a35746617.atlassian.net/rest/api/3/user/search?query=a35746617@gmail.com)

But i am getting the empty response, like i am not getting data of that user in jsonarray.

And also can you specify the value that i need to pass for reporter?

fields.put("reporter", new JSONObject().put("id", reporterAccountId));. this is not full code. but i send the jsonobject as data for creating ticket in jira software.


author: Jehan Bhathena
body: Hi [@Rakesh](/t5/user/viewprofilepage/user-id/5541290)

For the User search api, your api is correct. Does your User have access to the user administration though, since without that permission it may not be feasible to get an results.

About the fields.put() don't have much insights into that.


author: Rakesh
body: [@Jehan Bhathena](/t5/user/viewprofilepage/user-id/5119409)

Actually I am the project Admin and i am trying to give my accountId as value for reporter field.And i am doing that by using the code. I will tell the process,  
First i need to fetch the user details by using the gmail.  
second i will fetch the accountId from that details and pass it as value for the reporter field.

How can i check this "Does your User have access to the user administration though"? and

is accountId should be passed for reporter field right?


author: Jehan Bhathena
body: Use Control + K on your keyboard and search for 'Global Permissions', if you have access to this that means you have Jira Admin access.

Check for the "*Browse users and group", this* permission needs to be available for the users to be searchable.

After this to verify your access, click on the cog icon and see the options listed there, if you see Administration settings and the User Administration settings, then u have site administration access (feel free to share the image here if you require assistance for this)


author: Rakesh
body: [@Jehan Bhathena](/t5/user/viewprofilepage/user-id/5119409)   

Thank You for the Help!  
The Issue is solved.


Tags: jira-software