I looked, but could not find any simple examples of how to get started with Atlassian's JIRA Rest Java Client API.
Are there any recent examples available?
Here is an example that I wrote up this weekend. Hopefully, it helps someone to get started quickly.
package com.opentable.jira.estimator;import com.atlassian.jira.rest.client.api.JiraRestClient;import com.atlassian.jira.rest.client.api.JiraRestClientFactory;import com.atlassian.jira.rest.client.api.SearchRestClient;import com.atlassian.jira.rest.client.api.domain.Filter;import com.atlassian.jira.rest.client.api.domain.SearchResult;import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;import com.atlassian.jira.rest.client.api.domain.Issue;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import java.net.URI;/** * Entry-point invoked when the jar is executed. */public final class TestJiraAPI {private static final Logger LOG = LoggerFactory.getLogger(TestJiraAPI.class); private TestJiraAPI() {}public static void main(String[] args) throws Exception {final JiraRestClientFactory factory =new AsynchronousJiraRestClientFactory(); final JiraRestClient jiraRestClient = factory .createWithBasicHttpAuthentication(new URI(Constants.JIRA_URL), Constants.USERNAME, Constants.TOKEN ); try (jiraRestClient) {final SearchRestClient searchRestClient = jiraRestClient.getSearchClient(); final Filter filter = searchRestClient.getFilter(50447).claim(); final SearchResult searchResult = searchRestClient.searchJql(filter.getJql()).claim(); //Cycle through search result to print out the list of issues that match the filter } }}
HI,
I faced with the 404 error due to using your example.
Could you pls specify do you use a user name or email as user.name?
Wich the token you use, from here https://id.atlassian.com/manage-profile/security/api-tokens
or
Base64.getEncoder().encodeToString(String.format("%s:%s", USER_EMAIL, JIRA_CLOUD_TK).getBytes());
And cloud you pls share your dependencies?
It looks like you're new here. Sign in or register to get started.