EXAMPLE : this is my sample for service resource hook, i'm using drupal 7. I have enabled the services module and ctools module. the end point is working fine, but when i browse the endpoint/commerce_rest/retrieve url is not working

It returns the following exception, exception 'ServicesException' with message 'Could not find resource retrieve.' as following:

/var/www/webui/drupal/sites/all/modules/services/includes/services.runtime.inc:359\nStack trace:\n#0
/var/www/webui/drupal/sites/all/modules/services/servers/rest_server/includes/RESTServer.inc(83): services_error('Could not find ...', 404)\n#1
/var/www/webui/drupal/sites/all/modules/services/servers/rest_server/includes/RESTServer.inc(36): RESTServer->getController()\n#2
/var/www/webui/drupal/sites/all/modules/services/servers/rest_server/rest_server.module(40): RESTServer->handle()\n#3 [internal function]: rest_server_server()\n#4
[internal function]: services_endpoint_callback('commerce_rest', 'retrieve')\n#6 
/var/www/webui/drupal/includes/menu.inc(516): call_user_func_array('services_endpoi...', Array)\n#7 
/var/www/webui/drupal/index.php(33): menu_execute_active_handler()\n#8 {main}

And the source code is:

function test_module_services_resources() {

   $resource = array(
      'commerce_rest' => array(
      'retrieve' => array(
        'file' => array('type' => 'inc', 'module' => 'search_service'),
        'callback' => 'test_module_search_service_results',
        'access callback' => 'search_access_callback',
        'access arguments' => array('view'),
        'access arguments append' => TRUE, 
    return $resource;

this hook is not invoked, when I browse the url.


1 Answer 1


You can try:

 * Implements hook_services_resources
function test_module_services_resources() {

  $resources = array();

  $resources['search_results'] = array(
    'index' => array(
    'callback' => 'test_module_search_service_results_index',
    'file' => array(
      'type' => 'inc',
      'module' => 'test_module',
      'name' => 'resources/search_results.resource'
    'access arguments' => array('access content'),
    'args' => array(),

  return $resources;


Ensure the resource callback test_module_search_service_results_index is located in your module subfolder


Then try hitting http://www.example.com/api/search_results (using your site services endpoint)

  • 1
    Worth mentioning that the resources are all cached and you need to manually clear all caches (admin/config/development/performance)
    – jabal
    Feb 28, 2014 at 19:27
  • Unfortunately ´drush cc all´ doesn't clear the resources cache. Any idea how to clear it via drush? May 7, 2015 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.