Forums

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

Can't create an issue anymore with jira-rest-java-client-core

Victor Mosin July 17, 2019

I've been using those library for a year and it was fine. Approx. 1 or 2 weeks ago it stoped to work.

 

POM

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.2-2bd0a62e</version>
</dependency>
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>4.7.2</version>
<scope>provided</scope>
</dependency>

 

Java

BasicIssue task = jiraRestClient.getIssueClient().createIssue(taskBuilder.build()).claim();

Server respond with

com.atlassian.jira.rest.client.api.RestClientException: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 10 of











<html>

<head>








<title>Unauthorized (401)</title>







<!--[if IE]><![endif]-->
<script type="text/javascript" >
var contextPath = '';
var DeferScripts = { deferState: 'disabled' };
</script>
<script>

....

com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:45) ~[jira-rest-java-client-core-5.1.2-2bd0a62e.jar:na]
at com.smoope.utils.testcasegenerator.TestCaseGeneratorApplication.run(TestCaseGeneratorApplication.java:77) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:790) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at TestCaseGeneratorApplication.main(TestCaseGeneratorApplication.java:46) [classes/:na]
Caused by: com.atlassian.jira.rest.client.api.RestClientException: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 10 of

 

2 answers

1 accepted

0 votes
Answer accepted
Aleksandr Zuevich
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 18, 2019

Hi Victor,

Basic authentication with passwords and cookie-based authentication are now deprecated and disabled. 

"The deprecation period for this functionality has ended. From June 3rd, 2019, we will be progressively disabling the usage of this authentication method" - https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

You can use Basic Authentication with tokens instead of credentials.

Ben
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.
April 22, 2020

So what java library should we use instead?  I suppose we need to write our own `AuthenticationHandler` to implement the new way of doing things.  

Aleksandr Zuevich
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.
April 23, 2020

Hi Ben,

It seems you just need to use API token instead of password. 

gianluca-valentini
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!
April 6, 2022 edited

Hi, 

I used the API Token too but I have the same error. Using jira-rest-java-client-core v 5.2.4

Is there something that I can do to solve it?

 

private JiraRestClient getJiraRestClient() {

BasicHttpAuthenticationHandler authenticationHandler = new BasicHttpAuthenticationHandler(this.username, this.password);

return new AsynchronousJiraRestClientFactory().createWithAuthenticationHandler(getJiraUri(), authenticationHandler);
}

private URI getJiraUri() {
return URI.create(this.jiraUrl);
}

where I use the api-token instead of the password. But It does not work

0 votes
Ben
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.
April 22, 2020 edited

---

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events