Rest api with java » History » Version 18
Alex Last, 2016-08-11 06:45
deleted highly outdated legacy libraries
| 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 | "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) |
||
| 6 | |||
| 7 | 14 | Terence Mill | Sample usage: |
| 8 | 1 | Jean-Philippe Lang | |
| 9 | |||
| 10 | 17 | Alex Last | <pre> |
| 11 | String uri = "https://www.hostedredmine.com"; |
||
| 12 | String apiAccessKey = "a3221bfcef5750219bd0a2df69519416dba17fc9"; |
||
| 13 | String projectKey = "taskconnector-test"; |
||
| 14 | Integer queryId = null; // any |
||
| 15 | 1 | Jean-Philippe Lang | |
| 16 | 17 | Alex Last | RedmineManager mgr = RedmineManagerFactory.createWithApiKey(uri, apiAccessKey); |
| 17 | IssueManager issueManager = mgr.getIssueManager(); |
||
| 18 | List<Issue> issues = issueManager.getIssues(projectKey, queryId); |
||
| 19 | for (Issue issue : issues) { |
||
| 20 | System.out.println(issue.toString()); |
||
| 21 | } |
||
| 22 | 15 | Alex Last | |
| 23 | 17 | Alex Last | // Create issue |
| 24 | Issue issueToCreate = IssueFactory.createWithSubject("some subject"); |
||
| 25 | Issue createdIssue = issueManager.createIssue(projectKey , issueToCreate); |
||
| 26 | 15 | Alex Last | |
| 27 | 17 | Alex Last | // Get issue by ID: |
| 28 | Issue issue = issueManager.getIssueById(123); |
||
| 29 | 15 | Alex Last | </pre> |