Rest api with csharp » History » Version 4
Seung Soo Mun, 2022-04-15 16:36
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 | 4 | Seung Soo Mun | To use this library from PowerShell, see [[REST API with PowerShell]] |
6 | |||
7 | 1 | Dorin Huzum | Sample usage: |
8 | 2 | Dorin Huzum | |
9 | <pre> |
||
10 | using System; |
||
11 | using System.Collections.Specialized; |
||
12 | using Redmine.Net.Api; |
||
13 | using Redmine.Net.Api.Types; |
||
14 | |||
15 | namespace RedmineTest |
||
16 | { |
||
17 | class Program |
||
18 | { |
||
19 | static void Main(string[] args) |
||
20 | { |
||
21 | string host = ""; |
||
22 | string apiKey = ""; |
||
23 | |||
24 | var manager = new RedmineManager(host, apiKey); |
||
25 | |||
26 | var parameters = new NameValueCollection {{"status_id", "*"}}; |
||
27 | 3 | Guriy Samarin | foreach (var issue in manager.GetObjects<Issue>(parameters)) |
28 | 2 | Dorin Huzum | { |
29 | Console.WriteLine("#{0}: {1}", issue.Id, issue.Subject); |
||
30 | } |
||
31 | |||
32 | //Create a issue. |
||
33 | var newIssue = new Issue { Subject = "test", Project = new IdentifiableName{Id = 1}}; |
||
34 | manager.CreateObject(newIssue); |
||
35 | |||
36 | } |
||
37 | } |
||
38 | } |
||
39 | </pre> |