Rest api with java » History » Revision 11
Revision 10 (Alex Last, 2011-02-10 22:18) → Revision 11/19 (Etienne Massip, 2012-05-31 19:53)
h1. Using the REST API with Java "Redmine Java API library":https://github.com/taskadapter/redmine-java-api library":https://code.google.com/p/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. Sample usage: <pre> import java.io.IOException; import java.net.URISyntaxException; import java.util.List; import org.redmine.ta.beans.Issue; public class Simple { private static String redmineHost = "https://www.hostedredmine.com"; private static String apiAccessKey = "a3221bfcef5750219bd0a2df69519416dba17fc9"; private static String projectKey = "taskconnector-test"; private static Integer queryId = null; // any public static void main(String[] args) { RedmineManager mgr = new RedmineManager(redmineHost, apiAccessKey); try { tryGetIssues(mgr); } catch (Exception e) { e.printStackTrace(); } } private static void tryGetIssues(RedmineManager mgr) throws Exception { List<Issue> issues = mgr.getIssues(projectKey, queryId); for (Issue issue : issues) { System.out.println(issue.toString()); } } } </pre> Create Issue: <pre> Issue issueToCreate = new Issue(); issueToCreate.setSubject("This is the summary line 123"); Issue newIssue = mgr.createIssue(PROJECT_KEY, issueToCreate); </pre> Get issue by ID: <pre> Issue issue = mgr.getIssueById(123); </pre>