Rest api with csharp » History » Revision 5
Revision 4 (Seung Soo Mun, 2022-04-15 16:36) → Revision 5/6 (Maxim Okunev, 2024-08-19 21:55)
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. To use this library from PowerShell, see [[REST API with PowerShell]] 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 = ""; string issueId = "<issue-id>"; var manager = new RedmineManager(host, apiKey); //parameter - fetch associated relations. var parameters = new NameValueCollection {{RedmineKeys.INCLUDE, RedmineKeys.RELATIONS}}; var {{"status_id", "*"}}; foreach (var issue = manager.GetObject<Issue>(issueId, parameters); in manager.GetObjects<Issue>(parameters)) Console.WriteLine("Issue: {0}.", issue); { Console.WriteLine("#{0}: {1}", issue.Id, issue.Subject); } //Create a issue. Issue newissue var newIssue = new Issue(); newissue.Project Issue { Subject = IdentifiableName.Create<IdentifiableName>(id: 1); newissue.Tracker "test", Project = IdentifiableName.Create<IdentifiableName>(id: 1); newissue.Subject new IdentifiableName{Id = "Example"; 1}}; newissue.Description = "Description"; Issue savedIssue = manager.CreateObject(newissue); manager.CreateObject(newIssue); } } } </pre>