Project

General

Profile

Rest api with csharp » History » Revision 3

Revision 2 (Dorin Huzum, 2011-10-04 23:21) → Revision 3/4 (Guriy Samarin, 2019-12-11 13:00)

h1. Using the REST API with .NET 

 "Redmine .NET API library":https://code.google.com/p/redmine-net-api is a FREE third-party C# library that can be used to access the Redmine API. It is released under Apache 2 open-source license. 

 Sample usage: 

 <pre> 
 using System; 
 using System.Collections.Specialized; 
 using Redmine.Net.Api; 
 using Redmine.Net.Api.Types; 

 namespace RedmineTest 
 { 
     class Program 
     { 
         static void Main(string[] args) 
         { 
             string host = ""; 
             string apiKey = ""; 

             var manager = new RedmineManager(host, apiKey); 

             var parameters = new NameValueCollection {{"status_id", "*"}}; 
             foreach (var issue in manager.GetObjects<Issue>(parameters)) manager.GetObjectList<Issue>(parameters)) 
             { 
                 Console.WriteLine("#{0}: {1}", issue.Id, issue.Subject); 
             } 

             //Create a issue. 
             var newIssue = new Issue { Subject = "test", Project = new IdentifiableName{Id =    1}}; 
             manager.CreateObject(newIssue); 

         } 
     } 
 } 
 </pre>