Project

General

Profile

Rest api with java » History » Version 19

Alex Last, 2021-04-05 19:16

1 1 Jean-Philippe Lang
h1. Using the REST API with Java
2 2 Alex Last
3 1 Jean-Philippe Lang
h2. Redmine Java API library from taskadapter
4
5 19 Alex Last
"Redmine Java API library":https://github.com/taskadapter/redmine-java-api is a FREE third-party Java library that can be used to access the Redmine API. It is released under Apache 2 open-source license.
6 14 Terence Mill
Sample usage:
7 1 Jean-Philippe Lang
8
9 17 Alex Last
<pre>	
10
    String uri = "https://www.hostedredmine.com";
11
    String apiAccessKey = "a3221bfcef5750219bd0a2df69519416dba17fc9";
12
    String projectKey = "taskconnector-test";
13
    Integer queryId = null; // any
14 1 Jean-Philippe Lang
        
15 17 Alex Last
    RedmineManager mgr = RedmineManagerFactory.createWithApiKey(uri, apiAccessKey);
16
    IssueManager issueManager = mgr.getIssueManager();
17
    List<Issue> issues = issueManager.getIssues(projectKey, queryId);
18
    for (Issue issue : issues) {
19
        System.out.println(issue.toString());
20
    }
21 15 Alex Last
22 17 Alex Last
    // Create issue
23
    Issue issueToCreate = IssueFactory.createWithSubject("some subject");
24
    Issue createdIssue = issueManager.createIssue(projectKey , issueToCreate);
25 15 Alex Last
26 17 Alex Last
    // Get issue by ID:
27
    Issue issue = issueManager.getIssueById(123);
28 15 Alex Last
</pre>