Accessing Jira with Python using suds
By: Jens in python
We are using Jira as an Issue and Bug tracker at work. Lately we had the need to access it from external systems. Luckily Jira itself does provide a remote API in form of XML-RPC and SOAP. And i did not have any language constraints, so i could use python ;-) After looking in the API docs i noticed they do also provide some python examle. Great, even they use SOAPPy. SOAPPy does not work in python >= 2.5 and seem to be dead anyways. Some googling later i found the new soap kid for python, suds. And its dead simple. Heres an example accessing the public jira with their tutorial users:
from suds.client import Client client = Client('http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl') auth = client.service.login('soaptester', 'soaptester')
Import suds, create a Client object with the wsdl file you'd like t use and here you go. Suds does use the endpoint declared in the wsdl and does support also multiple endpoints. Each method of the webservice is exposed as a method on the clients service object with the exact name. So when accessing jira ones code will look a bit camelCased.
Jira users can create Filters for issue searches. With the getFavouriteFilters method these can be read by the api. Lets get them for our test user:
from suds.client import Client client = Client('http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl') auth = client.service.login('soaptester', 'soaptester') filters = client.service.getFavouriteFilters(auth) print filters for filter in filters.getFavouriteFiltersReturn: print filter['name'] print filter['id']
Of course when we are done, we should logoff.
client.service.logout(auth)
Take a look at the jira api documentation for an overview of what can be done with the api. The most helpful info for coding is the javadoc of their service class as one cant understand the parameters when only using the wsdl....
Happy hacking.




on 20 October 2009 at 08:33 Poulpatine said …
Hi,
I'm trying to automate Issue creation in Jira with a Python/suds script but I meet troubles with customfields.
Have you ever done that ?
Many thanks,
Poulpatine.
on 26 October 2009 at 04:10 Bill said …
This was helpful for me in terms of getting info. But when I try to do updateIssue I run into a problem where suds (I think) complains that it "Found character data inside an array element while deserializing". Have you successfully been able to do updates? I wrote down all the details on stackoverflow if you're interested: http://stackoverflow.com/questions/1609666/suds-jira-saxexception Good work. Thanks again!
on 26 October 2009 at 04:25 Jens said …
@Poulpatine
Besides reading stuff i've only used addComment and progressWorkflowAction so far. With the addComment id di have some trouble and had to use the dusd factory to create schema compliant elements, i.e.:
jira_comment = self.client.factory.create('tns1:RemoteComment')
jira_comment.body = comment
self.client.service.addComment(self.auth, issue_key, jira_comment)
@Bill
Do you get a Soap response or something else? Enable the logger for suds transport and look what you get.
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
on 12 May 2010 at 08:37 Micheál said …
Good man - a nice simple way to get started with SUDS and Jira. This was just what I was looking for.
Thanks for a great post.
on 31 August 2010 at 14:10 Matt Doar said …
FYI, I'm in the process of updating the Python CLI for JIRA to use suds instead of SOAPpy
~Matt
on 25 March 2011 at 02:21 Milind said …
Hi,
I am using Python 2.7.1 version on Windows. I have installed the suds module (0.4) version.
I am trying to import suds module but its throwing exception "ImportError: No module named suds".
Please Help........