Project

General

Profile

Rest api with java » History » Revision 6

Revision 5 (Alex Last, 2010-12-28 05:45) → Revision 6/19 (Jean-Philippe Lang, 2010-12-28 17:32)

h1. Using the REST API with Java 

 "Redmine Java API library":http://www.taskadapter.com/redmine_java_api is a commercial third-party (commercial software) 
 _The Redmine Java library that can be used to access the Redmine API. API distributive has Javadoc and more samples._ 

 "Browse Javadoc":http://www.taskadapter.com/javadoc/index.html 

 (*page under construction*) 

 Sample usage: 

 
 <pre> 
 import java.io.IOException; 
 import java.util.List; 

 import org.alskor.httputils.AuthenticationException; 
 import org.alskor.httputils.NotFoundException; 
 import org.alskor.redmine.RedmineManager; 
 import org.alskor.redmine.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 String Integer = 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 IOException, AuthenticationException, NotFoundException { 
		 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> 

 "Browse Javadoc":http://www.taskadapter.com/javadoc/index.html