I've released a new open source project named MantisSharp, a simple .NET client for working with the recently introduced REST API for Mantis Bug Tracker.

The library is just getting started and is missing various functions (hello documentation!) but it seems to be usable - as well as the WinForms sample browser that I was using for development testing, I also tested it in an ASP.NET MVC application, both locally and then remotely using the development version of cyotek.com.

It's probably not ready for prime time, I need to add docs, samples and finally get serious about using await/async, plus get a .NET Standard build done. But I think it's getting off to a good start.

The GitHub repository can be found at https://github.com/cyotek/MantisSharp - the readme has lots of extra details so I'm not going to repeat it here.

Why create this library?

Originally I wanted to use the MantisBT REST API to automatically generate the product roadmaps on cyotek.com - currently these are manual, and looking at the last modification dates on the content entries shows the latest update was in 2015. Ouch. As I've been properly planning releases in our MantisBT instance, it made sense to use that data. However, I don't want to open access (anonymous or otherwise) to the MantisBT instance itself, hence deciding to use the new API they added recently.

I wasn't planning create a full blown library, I thought I'd just load the JSON into a dynamic and grab what I needed that way. But that untyped code offended me so much (and oddly enough there didn't seem to be another client out there from a very brief check of NuGet) that in the end it was inevitable.

Assuming more than just me uses this library I'd love to hear your feedback.

Getting Started

As well as the source, you can grab precompiled binaries via a NuGet package

bat
Install-Package MantisSharp -Pre

The package includes builds for .NET 3.5, 4.0, 4.5 and 4.6. 4.7 will follow when I pave my machine and get the Creators Update, .NET Standard will follow as soon as I actually add it as a target and resolve any API issues.

Then just create an instance of the MantisClient, passing the base URI where your MantisBT installation is hosted, along with an API key. Also note that by default the REST API is disabled and needs to be explicitly switched on for external access. (There's a wiki page which tells you how).

csharp
MantisClient client = new MantisClient("YOUR_MANTIS_URI", "YOUR_API_KEY");

// list all projects
foreach (Project project in client.GetProjects())
{
  Console.WriteLine(project.Name);
}

// list all issues
foreach (Issue issue in client.GetIssues())
{
  Console.WriteLine(issue.Summary);
}

// list issues for a single project
var issues = client.GetIssues(4); // or pass in a Project reference

// get a single issue
Issue issue = client.GetIssue(52);

Known Issues

There's still outstanding work to do, some of which is detailed in the readme. I also haven't done much testing yet, and our MantisBT database is currently quite small, so I don't know how the library will perform under bigger databases.

Examples

An example of the WinForms demonstration application
An example of the WinForms demonstration application
An example of creating a roadmap type page using the REST API
An example of creating a roadmap type page using the REST API

Update History

  • 2017-07-10 - First published
  • 2020-11-22 - Updated formatting

Like what you're reading? Perhaps you like to buy us a coffee?

Donate via Buy Me a Coffee

Donate via PayPal


Comments

# Dev

Have you seen

https://github.com/DalSoft/DalSoft.RestClient

it can do strong typing on the fly. It's designed so you don't have to create individual clients for every API.

The code would almost be identical: List = client.Issues(4).Get();

Might be worth using it in your client to simplify things

Reply

# Richard Moss

Thanks for the suggestion.

From looking at the readme, this isn't something I'm going to be interested in... I wrote this particular client specifically because I dislike dynamic code. My goal for this library at present is also to keep it dependency free.

Regards; Richard Moss

Reply

# asghar

hi. how i can connect to my localhost mantis server?

Reply