Redmine logo

This is a new Drupal 7 module, for helping developers to integrate Drupal with Redmine, with two main uses:

  1. The redmine_rest_api_call() function, which can make a single call to a Redmine instance, using either JSON or XML, and return the result
  2. An admin page for trying out API calls so developers (with devel enabled) can see what results will be returned

Drupal 6 users see the Redmine API module.

For a good example of this module being used, see the Redmine Issues module by the same maintainer.

IMPORTANT: This module creates a user profile field for caching the logged in user's API key. This is only used if your Redmine version is prior to 2.2.0, before user masquerading via HTTP headers was available as an option, so if you are using 2.2.0+ then you can simply delete this field. However, if you are using versions prior to 2.2.0, be aware of two things:

  • You *must* apply this (very simple) patch to Redmine so it can look up user API keys (which is infinitely preferable to httpauth).
  • If you intend to share user profile data, as this should not be shared with non-privileged users. If you must share user profile fields, please look at modules for making individual profile fields private, such as User Field Privacy.

This module requires the Entity API for caching API keys.

Here is the inline documentation for the API call function:

/**
 * Make an API call to a given Redmine URL and return the
 * decoded result.
 *
 * @param string $fetch
 *  The portion of the URL to hit for our JSON query,
 *  e.g. 'projects/my_project'.
 * @param array $params
 *  An optional keyed array of additional parameters to pass
 *  into Redmine after the key param, in the format of
 *  'param_name' => 'value'.
 * @param string $method
 *  The HTTP method to pass to drupal_http_request().
 * @param string $data
 *  String of data to post to Redmine, if required.
 * @param string $api_type
 *  String denoting whether this is an XML or JSON call.
 *  Defaults to 'json', can be set to 'xml'.
 * @param string $login
 *  For Redmine 2.2.0+ the username of the user to impersonate
 *  when carrying out this action (must match their Redmine
 *  'login'). For older versions of Redmine, the user's API
 *  key.
 * @param string $api_key
 *  Optionally pass an alternative API key to use for the
 *  call. If not provided, we will use the API key stored in
 *  the Drupal variable 'redmine_rest_api_api_key'.
 * @param string $base_redmine
 *  Optionally pass an alternative Redmine server URL to
 *  provide support for multiple Redmine instances. If not
 *  provided, we will use the Redmine server URL stored in
 *  the Drupal variable 'redmine_rest_api_redmine_base_url'.
 *
 * @return
 *  The HTTP request result object or NULL if the call
 *  completely failed to illicit a response. The decoded
 *  data from Redmine will be in $result->decoded_data if
 *  available.
 */

Read the Redmine API docs to use the correct parameters for the different Redmine API options.

This module was originally developed for the Code Enigma Support Dashboard.

Module written by Greg Harvey.

Supporting organizations: 
Wrote and maintained.

Project information

Downloads