~2012
Redmine API and python
Since I could hardly find any documentation on using the Redmine REST API with python here are some examples. I wanted to add them to the Redmine Wiki but didn't want to register an account there...
accounts here, accounts there, accounts everywhere.
I've had best results using the pyactiveresource library. I suggest you do the same :)
The most difficult part I had to figure out was doing the authentication using the api key. Well here it is:
from pyactiveresource.activeresource import ActiveResource
class Project(ActiveResource):
_site = "http://demo.redmine.org"
_headers = {'X-Redmine-API-Key': "your key"}
projects = Project.find(None,None,limit=10)
for i, v in enumerate(projects):
print 'project [',i,']',' = ', v
for item in projects[i].attributes:
print item, " = ", projects[i].attributes[item]
print '======================'
Create an issue:
from pyactiveresource.activeresource import ActiveResource
class Issue(ActiveResource):
_site = "http://demo.redmine.org"
_headers = {'X-Redmine-API-Key': "your key"}
newIssue = Issue({'subject': "Example", 'project_id': 1, 'priority': 2})
newIssue.save()