Project

General

Profile

Rest api with csharp » History » Version 2

Dorin Huzum, 2011-10-04 23:21

1 1 Dorin Huzum
h1. Using the REST API with .NET
2
3
"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.
4
5
Sample usage:
6 2 Dorin Huzum
7
<pre>
8
using System;
9
using System.Collections.Specialized;
10
using Redmine.Net.Api;
11
using Redmine.Net.Api.Types;
12
13
namespace RedmineTest
14
{
15
    class Program
16
    {
17
        static void Main(string[] args)
18
        {
19
            string host = "";
20
            string apiKey = "";
21
22
            var manager = new RedmineManager(host, apiKey);
23
24
            var parameters = new NameValueCollection {{"status_id", "*"}};
25
            foreach (var issue in manager.GetObjectList<Issue>(parameters))
26
            {
27
                Console.WriteLine("#{0}: {1}", issue.Id, issue.Subject);
28
            }
29
30
            //Create a issue.
31
            var newIssue = new Issue { Subject = "test", Project = new IdentifiableName{Id =  1}};
32
            manager.CreateObject(newIssue);
33
34
        }
35
    }
36
}
37
</pre>