Project

General

Profile

Rest api with java » History » Version 16

Leonardo Pacheco, 2015-01-22 21:19
Updated the version of Redmine supported by redline-java-api

1 1 Jean-Philippe Lang
h1. Using the REST API with Java
2 2 Alex Last
3 14 Terence Mill
h2. Jredmine
4
5
"Jredmine":http://maven-site.nuiton.org/jredmine/index.html (implements its own redmine plugin and correspodnsing java client - more other/features than redmine rest api)
6
7
h2. redmine-jconnector
8
9
"redmine-jconnector":https://code.google.com/p/redmine-jconnector/ (only until redmine 1.4 using REST API)
10
11
h2. Redmine Java API library from taskadapter
12
13 16 Leonardo Pacheco
"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. (support until Redmine 2.6.0 using REST API)
14 2 Alex Last
15
Sample usage:
16 6 Jean-Philippe Lang
17 2 Alex Last
<pre>
18 1 Jean-Philippe Lang
19 15 Alex Last
	String uri = "https://www.hostedredmine.com";
20
	String apiAccessKey = "a3221bfcef5750219bd0a2df69519416dba17fc9";
21
	String projectKey = "taskconnector-test";
22
	Integer queryId = null; // any
23
        
24
        ...
25
	
26
        RedmineManager mgr = RedmineManagerFactory.createWithApiKey(uri, apiAccessKey);
27
        IssueManager issueManager = mgr.getIssueManager();
28
        List<Issue> issues = issueManager.getIssues(projectKey, queryId);
29
        for (Issue issue : issues) {
30
            System.out.println(issue.toString());
31
        }
32 2 Alex Last
33 15 Alex Last
        // Create issue
34
	Issue issueToCreate = IssueFactory.createWithSubject("some subject");
35
	Issue createdIssue = issueManager.createIssue(projectKey , issueToCreate);
36 2 Alex Last
37 15 Alex Last
        // Get issue by ID:
38 2 Alex Last
39 15 Alex Last
	Issue issue = issueManager.getIssueById(123);
40 5 Alex Last
</pre>