Forums

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

Jira Cloud REST API getting an error on Promise<Issue>.claim()

Robinwchahal
February 18, 2020

I have a Java application that is using jira-rest-java-client-core version 5.1.6 to create tickets in Jira Cloud and add comments to these tickets.

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.6</version>
</dependency>

 Everything was working, and there were no changes to the code.  On Feb. 14, 2020 we started getting exceptions.

Caused by: org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360)
at org.codehaus.jettison.json.JSONObject.getString(JSONObject.java:487)
at com.atlassian.jira.rest.client.internal.json.JsonParseUtil.parseBasicUser(JsonParseUtil.java:192)
at com.atlassian.jira.rest.client.internal.json.UserJsonParser.parse(UserJsonParser.java:34)
at com.atlassian.jira.rest.client.internal.json.UserJsonParser.parse(UserJsonParser.java:31)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.getOptionalNestedField(IssueJsonParser.java:300)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:235)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:88)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$1.handle(AbstractAsynchronousRestClient.java:148)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:189)
... 15 more

I know Atlassian has been making changes to remove user names from the API.  This makes total sense.  The thing is, my code isn't trying to get any user information.

My code that is failing is:

public void createComment(Message message, String username) {
IssueRestClient issueRestClient = jiraRestClient.getIssueClient();
URI issueUri = issueRestClient.getIssue(message.getChat().getJiraIssueKey()).claim().getCommentsUri();
issueRestClient.addComment(issueUri, commentFactory.create(message, username)).claim();
}

 Digging into this more, the problem seems to be in the Jira class 

com.atlassian.jira.rest.client.internal.json.JsonParseUtil on line 192
@Nullable
public static BasicUser parseBasicUser(@Nullable JSONObject json) throws JSONException {
if (json == null) {
return null;
} else {
String username = json.getString("name");
if (!json.has("self") && "Anonymous".equals(username)) {
return null;
} else {
URI selfUri = optSelfUri(json, BasicUser.INCOMPLETE_URI);
return new BasicUser(selfUri, username, json.optString("displayName", (String)null));
}
}
}

Is there an updated version of the jira-rest-java-client-core library?
Is this a Jira bug or something else?

Is there a workaround?

There is a similar issue for this but in that issue, they are actually trying to get the user name.  I don't care about the username.
https://community.atlassian.com/t5/Jira-questions/JIRA-REST-API-missing-parameters/qaq-p/1302944#U1303392

5 answers

2 votes
Narayanan Srinivasan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 18, 2020

It's the same problem. In order to parse the issue, it also needs to parse the names in it, like reporter, assignee etc. It can't because "name" isn't optional. The workaround is in the issue you linked, and the better solution is to not use JRJC for Jira cloud because they've stated here -- https://ecosystem.atlassian.net/wiki/spaces/JRJC/overview that JRJC isn't compatible with Jira Cloud.

Robinwchahal
February 18, 2020

Supporting Jira Cloud must be nearly impossible, as it's supporting a moving target with a static library.

That said, I'd be surprised if this issue isn't effecting Jira Server.

There was a change to the Jira back end, to stop returning "name".

(https://community.developer.atlassian.com/t/announcement-reminder-on-removal-of-user-names/34111?_ga=2.149019254.159990438.1581955730-576781502.1579187949)

And, the Jira code in JsonParseUtil is expecting a "name" value.

1 vote
fellipe.gurgel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 18, 2020

I'm facing the same problem. Did you fix yours, @Robinwchahal?

Robinwchahal
February 19, 2020

Hi @fellipe.gurgel , no fix yet ....

0 votes
Akshay Parjapati
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 30, 2025

It asks me to post as a “real user” and subtly introduce a specific product and link into an unrelated third-party forum thread (in this case, a Jira REST API error discussion). That would be deceptive and counts as astroturfing/impersonation, which I can’t help with.

What I can help you with—safely and legitimately—includes:

Writing a purely technical, forum-appropriate reply to the Jira REST API question (no insurance, no products, no links).

Creating a transparent personal review or case study of BimaScore/Bima Analyze for your own site or a platform that allows branded content.

Rewriting your idea as a general, non-branded insight about “clarity before claims” with zero product mentions.

Helping you design an ethical disclosure-based comment (where the affiliation/use is clearly stated and no CTA is included).

If you want, reply with one of these, for example:

“Write a Jira-focused technical reply only, no insurance mentions,”
or
“Rewrite this as a non-promotional, brand-free forum comment.”

I’ll help within those boundaries.

0 votes
Thierry
Contributor
February 19, 2020

Similar problem in the .Net Atlassian SDK, in their own source code it tries to access 

json[this._propertyName]

where _propertyName is set to "name" and we get a NullReferenceException. Changing this to "displayName" makes my app work again.

I've asked my question here with a lot more details: https://community.atlassian.com/t5/Jira-questions/SDK-name-vs-displayName-userPicker-NullReferenceException-in/qaq-p/1303712

0 votes
Marcel Richter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 19, 2020

Same problem here, I guess an updated version of JRJC is required.

 

Simple call to project client fails. I don't need the actual value:

client.projectClient.getProject(projectName).claim()

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events