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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Exception while trying to read an issue using jira-rest-java-client Edited

Dear Community,

I am using jira-rest-java-client to read an issue from JIRA Cloud


My code is fairly straight forward:


public static void main(String[] args) throws Exception
final JiraRestClientFactory
factory =
new AsynchronousJiraRestClientFactory();

final JiraRestClient
jiraRestClient =
new URI(Constants.JIRA_URL),

final IssueRestClient
issueClient =

final Promise<>
promiseIssue =

issue =


The issue is retrieved, but during the parsing of the author, the code is trying to retrieve attribute "name" which does not appear to exist in the JSON object.  


public static BasicUser parseBasicUser(@Nullable JSONObject json) throws JSONException {
if (json == null) {
return null;
final String username = json.getString("name");
if (!json.has(JsonParseUtil.SELF_ATTR) && "Anonymous".equals(username)) {
return null; // insane representation for unassigned user - JRADEV-4262

// deleted user? BUG in REST API: JRA-30263
final URI selfUri = optSelfUri(json, BasicUser.INCOMPLETE_URI);
return new BasicUser(selfUri, username, json.optString("displayName", null));

Instead, my object contains a field called "displayName".

As a result, the code in the  jira-rest-java-client library fails with the following exception:

Caused by: org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.
at org.codehaus.jettison.json.JSONObject.get(
at org.codehaus.jettison.json.JSONObject.getString(

Is there something that I am not doing correctly?  

Why does the object returned from JIRA Cloud does not include "name", but rather has "displayName" instead?  

More importantly, how do I fix this?

3 answers

1 accepted

1 vote
Answer accepted

There are a plethora of different JIRA clients hosted at Atlassian Artifactory and one of the issues was to figure out which one to use.  From other googling around I found out that version 



Corrects the issue that I was having.  In addition to this dependency, the following dependencies are also required:


After adding these dependencies, the error is gone and I am able to access JIRA Cloud REST API to complete the work I am doing.

DPK J Community Leader Apr 13, 2020

Good work @Alex Paransky 

I think newer versions have updated response parser for user object.

1 vote
DPK J Community Leader Apr 11, 2020

@Alex Paransky

To add to @Matt Doar__ LinkedIn  's answer,

This is know issue as of now with 'jira-rest-client' while using Jira Cloud and reason for this mishap is GDPR.

Jira's rest API's for Cloud have started returning 'accountId' for a user object in place of 'username' or 'email', and JSON parser is not update to take care of this change.

As a workaround you can use custom 'rest-client' (like uni-rest) for accessing Jira's rest api. Or you can extend existing library to reflect the change.

Hi @DPK J , 

I am using the following dependency



I am getting the following exception when I am creating an issue

at com.JrJcExample.JRJCExample.createIssue(
at com.JrJcExample.JRJCExample.main(
Caused by: java.lang.Exception: Error parsing JSON object.
at com.sun.jersey.json.impl.provider.entity.JSONObjectProvider.readFrom(
at com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$App.readFrom(
at com.sun.jersey.api.client.ClientResponse.getEntity(
at com.sun.jersey.api.client.ClientResponse.getEntity(
at com.sun.jersey.api.client.WebResource.handle(


Can you help me out on this, if I am trying to use jrjc core dependency I couldn't able to accomplish OAuth 1.0 authentication. I am getting this exception when I am using to create issue in Jira server, I am not getting any exception with cloud jira.

DPK J Community Leader Nov 29, 2020

Hey @poonam narwal sorry for the late response, I was on holidays.

Looking at error it seems you are not getting proper JSON.

Are you on Server or Cloud?

Hi @DPK J  No problem, Yes I couldn't able to recieve a proper response from the server, It is creating an issue in server but I am getting garbled text as a response. I came to know this once I have tried by calling rest API through java code. Here is my code.


Client client = Client.create();
OAuthClientFilter filter = new OAuthClientFilter(client.getProviders(), oAuthParameters, oAuthSecrets);
URI issueuri = new URI("<MY DOMAIN URL HERE>/rest/api/2/issue");
WebResource webResource = client.resource(issueuri);
String issueInput=getIssueInput(); //Here I am creating a json to a string

ClientResponse response = webResource.type("application/json").post(ClientResponse.class, issueInput.getBytes());
System.out.println("\nResponse Status Code = "+response.getStatus());
System.out.println("response.toString() : "+response.toString());

output = response.getEntity(String.class);

So, It is giving a response like

���� �`b�*� �VK��D�]�a<��N�����

Can I get any suggestion on this, exactly why it is creating this problem 

DPK J Community Leader Dec 01, 2020

I need to try this code out.

0 votes

I think that jira-rest-java-client  was written for Jira Server not Jira Cloud? Not sure of good examples for the cloud

Suggest an answer

Log in or Sign up to answer

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