2
votes

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.' in /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 /var/www/webui/drupal/sites/all/modules/services/services.module(218): call_user_func('rest_server_ser...')\n#5 [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}

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 suggestion will be appreciable..

1

1 Answers

2
votes

Hi You are missing the file name in the file argument

function test_module_services_resources() {

 $resource = array(
  'commerce_rest' => array(
  'retrieve' => array(
    'file' => array('type' => 'inc', 'module' => 'search_service', **'name' => "you are missing this"**),
    'callback' => 'test_module_search_service_results',
    'access callback' => 'search_access_callback',
    'access arguments' => array('view'),
    'access arguments append' => TRUE, 
    ),
  )
)
);
return $resource;
}