01 Jun 2010

Creating Trac tickets remotely with XML-RPC

Dev, Tech 2 Comments

Trac is a simple but powerful open source issue tracking and wiki system for software projects. We have used it successfully in our own internal projects and in projects for clients. Trac runs on a web server and is accessed via any browser, which means minimal deployment hassle and relatively painless upgrades. It is written in Python and is easily customized by means of plugins,  or, if you need even more customization than plugins can provide,  by editing the source code.

Larger organisations often make use of a number of disparate tools which do not natively talk nicely to each other and it is not always possible to replace legacy tools with a new enterprise-wide system. Such a scenario was presented to us by a client where the developers were using Trac to manage software issues and the ops team were using a third-party help desk system to log technical issues. What the client wanted was a way for a Trac ticket to be created automatically from a help desk request.

Fortunately, Trac provides a useful Remote Procedure Call API, the details of which are nicely summarized here. The API supports both XML-RPC and JSON-RPC protocols. We went the XML-RPC route. In order to use XML-RPC with Trac, one must first install the XML-RPC Plugin. Installing Trac plugins is pretty easy – the official instructions can be found here. So now your nice secure Trac system is open to all and sundry to mess with from afar…well, not quite. In order to access the XML-RPC API, you need the right permissions. Permissions can be assigned using the trac-admin tool. In addition to the regular trac permissions, a special permission, XML_RPC, is required in order to use the API. In our case we also assigned the TICKET_CREATE permission as that is the functionality we required.

Right, so you’ve hopefully managed to install the plugin and setup your permissions. How do you go about using the API? Well, there are a number of ways to go about doing this depending on your scenario, but it basically boils down to sending an xml-rpc message to the correct url, which should look something like this:

http://<tracServerIPaddress>:<portNumber>/trac/<yourTracInstanceName>/login/xmlrpc

an example might be: http://192.168.0.1:8181/trac/myTrac/login/xmlrpc

In our scenario, the client’s platform was Microsoft .Net, so we created an ASP.Net web service to access the API. Charles Cook of Cook Computing has kindly made available an XML-RPC library for .Net which takes care of the nitty gritty of creating and sending XML-RPC messages. This page has some useful information on using the library with Trac. The lads over at CodeResort.com also have some good information here and here (registration required).

I hope this article has provided useful information for other seekers. Be sure to check back for a follow-up article.

Andrew Rudman

2 Responses to “Creating Trac tickets remotely with XML-RPC”

  1. Frederic says:

    very helpful…

    I preferred to thank you for this good article. http://wxzal.tradea.org/ I by all odds liked every little bit of it…

Leave a Reply