Remote Procedure Call (RPC)

Installed API version : 1.1.2

Protocol reference:

Below you will find a detailed description of all the RPC protocols installed in this environment. This includes supported content types as well as target URLs for anonymous and authenticated access. Use this information to interact with this environment from a remote location.

Libraries for remote procedure calls and parsing exists for most major languages and platforms - use a tested, standard library for consistent results.

JSON-RPC

For JSON-RPC protocol, use any one of:

Example POST request using curl with Content-Type header and body:

user: ~ > cat body.json
{"params": ["WikiStart"], "method": "wiki.getPage", "id": 123}
user: ~ > curl -H "Content-Type: application/json" --data @body.json http://trac.zentyal.org/rpc
{"id": 123, "error": null, "result": "= Welcome to....

Implementation details:

  • JSON-RPC has no formalized type system, so a class-hint system is used for input and output of non-standard types:
    • {"__jsonclass__": ["datetime", "YYYY-MM-DDTHH:MM:SS"]} => DateTime (UTC)
    • {"__jsonclass__": ["binary", "<base64-encoded>"]} => Binary
  • "id" is optional, and any marker value received with a request is returned with the response.

XML-RPC

For XML-RPC protocol, use any one of:

There should be XML-RPC client implementations available for all popular programming languages. Example call using curl:

user: ~ > cat body.xml
<?xml version="1.0"?>
<methodCall>
<methodName>wiki.getPage</methodName>
<params>
<param><string>WikiStart</string></param>
</params>
</methodCall>
user: ~ > curl -H "Content-Type: application/xml" --data @body.xml http://trac.zentyal.org/rpc
<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><string>= Welcome to....

The following snippet illustrates how to perform authenticated calls in Python.

>>> from xmlrpclib import ServerProxy
>>> p = ServerProxy('http://anonymous:your_password@trac.zentyal.org/login/rpc')
>>> p.system.getAPIVersion()
[1, 1, 2]

RPC exported functions

system - Core of the RPC system.

Function Description Permission required
array system.multicall(array signatures) Takes an array of RPC calls encoded as structs of the form (in a Pythonish notation here): {'methodName': string, 'params': array}. For JSON-RPC multicall, signatures is an array of regular method call structs, and result is an array of return structures. XML_RPC
array system.listMethods() This method returns a list of strings, one for each (non-system) method supported by the RPC server. XML_RPC
string system.methodHelp(string method) This method takes one parameter, the name of a method implemented by the RPC server. It returns a documentation string describing the use of that method. If no such string is available, an empty string is returned. The documentation string may contain HTML markup. XML_RPC
array system.methodSignature(string method) This method takes one parameter, the name of a method implemented by the RPC server. It returns an array of possible signatures for this method. A signature is an array of types. The first of these types is the return type of the method, the rest are parameters. XML_RPC
array system.getAPIVersion() Returns a list with three elements. First element is the epoch (0=Trac 0.10, 1=Trac 0.11 or higher). Second element is the major version number, third is the minor. Changes to the major version indicate API breaking changes, while minor version changes are simple additions, bug fixes, etc. XML_RPC

ticket - An interface to Trac's ticketing system.

Function Description Permission required
array ticket.query(string qstr="status!=closed") Perform a ticket query, returning a list of ticket ID's. All queries will use stored settings for maximum number of results per page and paging options. Use max=n to define number of results to receive, and use page=n to page through larger result sets. Using max=0 will turn off paging and return all results. By resource
array ticket.getRecentChanges(dateTime.iso8601 since) Returns a list of IDs of tickets that have changed since timestamp. By resource
array ticket.getAvailableActions(int id) Deprecated - will be removed. Replaced by getActions(). By resource
array ticket.getActions(int id) Returns the actions that can be performed on the ticket as a list of [action, label, hints, [input_fields]] elements, where input_fields is a list of [name, value, [options]] for any required action inputs. By resource
array ticket.get(int id) Fetch a ticket. Returns [id, time_created, time_changed, attributes]. By resource
int ticket.create(string summary, string description, struct attributes={}, boolean notify=False, dateTime.iso8601 when=None) Create a new ticket, returning the ticket ID. Overriding 'when' requires admin permission. TICKET_CREATE
array ticket.update(int id, string comment, struct attributes={}, boolean notify=False, string author="", dateTime.iso8601 when=None) Update a ticket, returning the new ticket in the same form as get(). 'New-style' call requires two additional items in attributes: (1) 'action' for workflow support (including any supporting fields as retrieved by getActions()), (2) '_ts' changetime token for detecting update collisions (as received from get() or update() calls). Calling update without 'action' and '_ts' changetime token is deprecated, and will raise errors in a future version. By resource
int ticket.delete(int id) Delete ticket with the given id. By resource
struct ticket.changeLog(int id, int when=0) Return the changelog as a list of tuples of the form (time, author, field, oldvalue, newvalue, permanent). While the other tuple elements are quite self-explanatory, the permanent flag is used to distinguish collateral changes that are not yet immutable (like attachments, currently). By resource
array ticket.listAttachments(int ticket) Lists attachments for a given ticket. Returns (filename, description, size, time, author) for each attachment. By resource
base64 ticket.getAttachment(int ticket, string filename) returns the content of an attachment. By resource
string ticket.putAttachment(int ticket, string filename, string description, base64 data, boolean replace=True) Add an attachment, optionally (and defaulting to) overwriting an existing one. Returns filename. By resource
boolean ticket.deleteAttachment(int ticket, string filename) Delete an attachment. By resource
array ticket.getTicketFields() Return a list of all ticket fields fields. TICKET_VIEW