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

jira-rest-java-client-core 5.1.6 and JSONException

Hi!

I've been using com.atlassian.jira 5.1.6 library for a weeks and it was fine. Today (18/02/2020) it stoped to work. I have a org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.

Any idea please??  Thanks...

POM:

 

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

Java

String JQL_JIRA_ACTIVE_SUBPROYECTS = "issuetype = Epic AND project in (SRT) AND status = 'In Progress' ORDER BY cf[12818] DESC, lastViewed DESC";


AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
jiraClient = factory.createWithBasicHttpAuthentication(new URI(MY_URI), MY_USR, MY_TOKEN);
SearchResult result = (SearchResult) jiraClient.getSearchClient().searchJql(JQL_JIRA_ACTIVE_SUBPROYECTS).get();

 Error:

Throwable , RestClientException{statusCode=Optional.absent(), errorCollections=[]} :java.util.concurrent.ExecutionException: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at io.atlassian.util.concurrent.Promises$OfStage.get(Promises.java:353)
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.get(DelegatingPromise.java:101)
at TestConnetJira.test(TestConnetJira.java:79)
at TestConnetJira.main(TestConnetJira.java:41)
Caused by: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:191)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:185)
(...)
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)


 

7 answers

1 accepted

1 vote
Answer accepted

Good Morning.

First, excuse me for my English ... The problem is that jira, for a few days, does not return the "name" field of the user and when parsing the JSON, when not finding the parameter, it returned an exception.

I have solved it in a way that is not the best and I don't like it, but at the moment I couldn't find another one: decompile the class com.atlassian.jira.rest.client.internal.json.JsonParseUtil and in the parseBasicUser method replace:

username = json.getString ("name");

By

String username = "";
if (json.has ("name")) {
username = json.getString ("name");
}

I will be attentive to the next attlassian library in case they solve this problem since although it works in this way, you are modifying a foreign class and it is not the best solution.

I hope it helps you. A greeting and thanks for the help.

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-app</artifactId>
<version>5.2.0</version>
</dependency>

The latest dependency solves the issue

Looks like this is the cause. Jira Cloud API doesn't return name of user anymore. We also stuck with this error today.

https://developer.atlassian.com/cloud/confluence/rest/?_ga=2.68352215.737964662.1582108886-1288132870.1581605383#api-user-get

NOTE: Personal data that is used to identify users, such as username and userKey, has been removed from the Confluence Cloud REST API

 

Hi. it seems they hide information about userKey and usrname.

If we look into the getting user info we can not find data about userKey and usrname.

 

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-user-get

 

 "key": "",
  "accountId": "5b10a2844c20165700ede21g",
  "name": "",

+1

Assumption is that BasicAuthentication has been deprecated as the response message is the text:

"Basic auth with password is not allowed on this instance" 

As this is not in a JSON from you get the 

JSONObject["name"]

error as the error text is not in JSON format.

 

So it would seem that you need to authenticate via API tokens instead. Can't confirm this, but thats my assumption

Same problem here!

Hi, having the same problem with jira-rest-java-client-api-5.1.0 library.

Observed the issue was raised also here:
https://community.atlassian.com/t5/Jira-questions/REST-API-numerous-calls-now-throwing-an-error/qaq-p/1305234

And the reason behind it is:
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide

Not sure if an update for the libraries is available at the moment.

Stuck with the same thing when I try to do getIssue by passing the ticket number. Any idea how to fix this?

Suggest an answer

Log in or Sign up to
This widget could not be displayed.
TAGS

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