Version 69 (modified by Barbara Post, 8 years ago) (diff)

removed space in front of some blank lines (lines break were not effective because of these spaces)

Trac XML-RPC Plugin

Note about 0.11 compatibility

You can check out the tickets that users have created, there may be a solution to your problem. Especially #1075 states that it works out of the box with Eclipse-3.3 and Mylyn.


This plugin allows Trac plugins to export select parts of their interface via XML-RPC.

It also includes some exported functions for manipulating tickets, with plans to include interfaces to other parts of Trac's API.

The browsable XML-RPC URI suffix is /xmlrpc, however most XML-RPC clients should use the authenticated URL suffix /login/xmlrpc as this is correctly authenticated by Trac.

Note: if you do want to use /xmlrpc and unauthenticated access, you must grant the XML_RPC permission to the 'anonymous' user.

WikiRPC API is complete, mostly thanks to mgood.

Ticket API is also complete, with the following types exported: component, version, milestone, type, status, resolution, priority and severity.

For example, for TracHacks the URIs are and (must be authenticated).


Outstanding tasks are roadmap, timeline, user management (e.g. get a (filtered) user list to assign a task in mylyn), plugin management (?) probably more.


This plugin requires at least Trac 0.10. It will not work with Trac 0.9.x or earlier. Install in the same manner as any other Trac plugin:

# python bdist_egg 
# cp dist/*.egg /srv/trac/env/plugins 

or if you want it to be installed for all Trac environments:

# easy_install /path/to/unpacked/ 

(You might want to use easy_install -Z so that it doesn't need to be unpacked when it's called.) You will also probably need to enable the plugin in your environments trac.ini:

tracrpc.* = enabled 

Bugs/Feature Requests

Existing bugs and feature requests for XmlRpcPlugin are here. If you have any issues, create a new ticket.


Problems when AccountManagerPlugin is enabled

If you have the AccountManagerPlugin enabled and you followed their advice/example to disable the standard login module with

trac.web.auth.LoginModule = disabled 

the /login/xmlrpc URL for authorized access will not work as expected. Every access will look like anonymous access. You can use the HttpAuthPlugin to correct this.

Problems with Digest HTTP authentication

The xmlrpclib.ServerProxy client - as demonstrated in the following examples - will not work with a Digest-based HTTP authentication: you need to set up a Basic HTTP authentication on server side to make the examples work.

If you use the standalone Trac daemon, this means that you cannot use the tracd -a option (htdigest authentication file). Use trac --basic-auth (htpasswd authentication file) instead.

Problems with mod_python, Apache, python 2.4

XmlRpcPlugin might not work with Apache and python 2.4 as explained in TracInstall. Use python 2.5 if you want to run Trac with mod_python.

Download and Source

Download the [download:xmlrpcplugin zipped source], check out the source using Subversion or browse the source with Trac.


Python End-User Usage

Obtain and print a list of XML-RPC exported functions available to my user:

import xmlrpclib 
server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc") 
for method in server.system.listMethods(): 
  print method 
  print '\n'.join(['  ' + x for x in server.system.methodHelp(method).split('\n')]) 

The same example using system.multicall(). This reduces network and server load by compacting all of the system.methodHelp() calls into one HTTP POST.

import xmlrpclib 
server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac/devel/login/xmlrpc") 
multicall = xmlrpclib.MultiCall(server) 
for method in server.system.listMethods(): 
for help in multicall(): 
    lines = help.splitlines() 
    print lines[0] 
    print '\n'.join(['  ' + x for x in lines[2:]]) 

List all tickets that are owned by athomas, using the XML-RPC multicall system to issue multiple RPC calls with one HTTP request:

import xmlrpclib 
server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac/devel/login/xmlrpc") 
multicall = xmlrpclib.MultiCall(server) 
for ticket in server.ticket.query("owner=athomas"): 
print map(str, multicall()) 

Access the Wiki with WikiRPC

import xmlrpclib 
server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc") 
# print the content of WikiStart 
# print WikiStart as HTML 
# write to the SandBox page from a text file 
sandbox_content = file("sandbox.txt").read()"SandBox", sandbox_content, {"comment": "testing the WikiRPC interface"}) 

Add an attachment to WikiStart:

import xmlrpclib 
server = xmlrpclib.ServerProxy("http://athomas:password@localhost:8080/trunk/login/xmlrpc")'WikiStart/', xmlrpclib.Binary(open('').read())) 

Using from C#

See DotNet.

Using from Java

See this example zip file

Using from Ruby

You can either use the XMLRPC functionality included in the Ruby Standard Library or download the trac4r library which does all the trivial stuff for you.

trac4r Example

This example uses trac4r:

require 'trac4r/trac'
# initialize the connection (username and password can be ommitted if not needed, but most of the time you will need them if anonymous doesn't have XMLRPC permissions)
trac = "", "myusername", "mypassword"
# get a list of all tickets (as an array of numbers) :include_closed => true # this is the default anyway
# get all the tickets
# NOTE: the results here are cached, so you can call it as often as you want without producing traffic more than once.
# use ":cached_results => false" to get the latest version :include_closed => true
# get a single ticket
ticket = 5
# print the data
puts "Title: #{ticket.summary}"
puts "Description: #{ticket.description}"
puts "Milestone: #{ticket.milestone}"
puts "Status: #{ticket.status}"
puts "Type: #{ticket.type}"
puts "Priority: #{ticket.priority}"
# get a list of all wiki pages
# download one page "SomeRandomPageName" # HTML version "AnotherRandomPageName" # trac syntax version (e.g. for editing)
# for previews use "content of a page in [wiki:WikiFormatting Trac syntax] as a ''String''"
# to post a page use "NameOfThePage", "content in Trac syntax"
# list the attachments of a wiki page "NameOfThePage"
# save an attachment"my_cool_document","w") do |f|
  f.write "NameOfThePage", "my_cool_document.pdf"

Also see the included Documentation in trac4r/doc

If you need to do a custom query do


The first argument is the method name, all other arguments are directly passed to XMLRPC. For this example of cause you could do trac.api_version instead ;)

If you have any problems with trac4r you can email me: niklas.cathor (eat) gmail dot com

xmlrpc Example

An example using XML-RPC directly with Ruby to append to a wiki page:

require 'xmlrpc/client'
user = "username"
password = "password"
page_name = "SandBoxRPC"
new_content = "\n\nMy new content"
new_comment = "Adding new content from ruby"

server = XMLRPC::Client.new2("https://#{user}:#{password}")
content ="wiki.getPage", page_name) + new_content"wiki.putPage", page_name, content, {"comment" => new_comment})

API Usage

See the source for details.


If the HTTP request to this URI is not XML, the XmlRpcPlugin will list all exported functions that the current user has permission to use.

Change Log

16280 by rjollos on 2017-03-04 02:27:19
XmlRpcPlugin 1.1.7dev: Bump version

Refs #13092.

16279 by rjollos on 2017-03-03 06:21:51
XmlRpcPlugin 1.1.6: Fix test failures with Trac 1.2-stable

Refs #13066.

16278 by rjollos on 2017-03-03 05:41:23
XmlRpcPlugin 1.1.6: Require Trac >= 0.11

Fixes #9800.

16228 by rjollos on 2017-02-11 06:34:01
XmlRpcPlugin 1.1.6: Fix tracebacks in log file

  • Prevent logging tracebacks when receiving invalid data and log as a warning
  • Log messages without traceback when TracError, PermissionError and ResourceNotFound

Patch by Jun Omae.

Fixes #12408.

15969 by osimons on 2016-11-16 13:12:04
XmlRpcPlugin: Improve test case docs. Follow-up to [15968]. Refs. #12950.


Author: athomas
Contributors: mgood

Attachments (2)

Download all attachments as: .zip