Jira REST API access from java

Alexander kuttner October 21, 2021

So i want to get json data from my jira project which has a jql selection included:

https://(system).atlassian.net/rest/api/3/search?jql=project=(projectname) AND issuetype=Bug AND (priority = High OR priority = Blocker)

 

The problem is, that i have to authenticate myself to Jira, but unfortunately i don't know how to do that in Java.

I hope someone can help me out!

2 answers

0 votes
Brand October 21, 2021

Hey @Alexander kuttner, may I ask why don't you use a selfhosted environment? It is a lot easier there to authenticate, as you don't have to handle API tokens and 2FA ...

Alexander kuttner October 22, 2021

May i ask what a selfhosted environment is?

Brand October 22, 2021

When you have Jira installed on your servers, for example "jira.[yourdomain.com]", it is called "self hosted", instead of Jira cloud with [name].atlassian.net. Functions in Jira cloud (especially in the free tier) may be limited.

Alexander kuttner October 22, 2021

Ahh it's because we are doing a diploma and our manager gave it to us.

0 votes
Prince Nyeche
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.
October 21, 2021

Hi @Alexander kuttner 

Welcome to community. Please look at the sample code for Java to see an example of authenticating your user using REST API. For example

// This code sample uses the  'Unirest' library:
// http://unirest.io/java.html
HttpResponse<JsonNode> response = Unirest.get("https://your-domain.atlassian.net/rest/api/3/jql/autocompletedata")
  .basicAuth("email@example.com", "<api_token>")
  .header("Accept", "application/json")
  .asJson();

System.out.println(response.getBody());

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events