Creating an XML-RPC Client
JIRA 3.0 and later
JIRA ships with the JIRA XML-RPC plugin which enables remote access through XML-RPC and SOAP. Using this feature with XML-RPC is easy with some help from the Apache XML-RPCpackage.In this tutorial, we write a basic XML-RPC client (using Apache XML-RPC) that logs in, retrieves projects and then logs out again. A Python client is also demonstrated.You may also be interested in the Creating a JIRA SOAP Client. More methods are exposed via SOAP than XML-RPC.
To run the Java client in this tutorial, you'll need to download the Apache XML-RPC libraries and make them available in your classpath.
Enabling the RPC plugin
To invoke JIRA operations remotely, you should ensure that the RPC plugin is enabled on the JIRA installation you are targeting. If you simply want to create a client to http://jira.atlassian.com/ then you can skip this step. First you need to check if the Accept Remote API Calls has been enabled in 'General Configuration' under 'Global Settings' in the left-hand menu:
Then you need to enable the JIRA RPC Plugin in 'Plugins' under 'System' in the left-hand menu:
To get the source code of the RPC plugin, see https://bitbucket.org/atlassian_tutorial/jira-rpc-plugin
Your server should now be ready to accept remote procedure calls.
Now that your server is ready to accept remote procedure calls, we begin creating a Java XML-RPC client.
Building a Python XML-RPC client
XML-RPC in Python is very easy. Here is a sample client that creates test issues on http://jira.atlassian.com:
Building a Java client
The goal of this tutorial is to create a client that makes three simple remote calls to JIRA. Here we log in, retrieve the project information and then log out again. You can take a look at the full source code here (xmlrpc-2.x) or here (xmlrpc-3.x).
The first step is to configure your details.
All XML-RPC calls are invoked at with the path
/rpc/xmlrpc by default. You need to configure your username and password appropriately.
Method calls to JIRA via XML-RPC need to be prefixed with "
jira1.". Parameters to methods are passed as sequenced Objects in a Vector. In the above code, we log into jira.atlassian.com. We receive back a
loginToken which will need to be passed to all subsequent method calls.
The RPC client calls the getProjectsNoSchemes() method passing the loginToken. This returns with a Vector of projects which are represented by
HashTable objects. For information on what methods are available as well as what properties are available on returned projects, you'll again need to look at the JIRA XML-RPC API Spec.
Lastly, we log out of the system, again passing the loginToken in a Vector form.
There it is! A simple client for JIRA XML-RPC. If you wish to extend or customise the JIRA XML-RPC plugin itself, you can download the latest source from the repository.
Building a Perl client
Here's an XML-RPC client that uses the
XMLRPC::Lite module (distributed with ActivePerl and available for free on CPAN).
XMLRPC::Lite is poorly documented. Using it for this simple example required reading the code. We do not recommend it for newbie Perl hackers.