I've been using the Drupal basic services module with REST from quite some time now.

I would like to know if this possible:

    PUT request: http://example.com/endpoint/node/{X,Y,Z}

Basically, what I want to do is make only one PUT application/json request with an appropriate json raw body for it and having an array of resource_ids instead of making a loop for each PUT request to be handled. So far as I've read, I've only found this syntax:

   PUT request: http://.../resource_endpoint/resouce_name/resource_id
  • You can only do one request at a time. Otherwise, you'll have to implement a custom service resource to handle the batch operation for you. – tyler.frankenstein Feb 10 '15 at 15:03

You could use service hook, and follow the step:

Using hook_services_resources to tell Drupal's Services module that you have some REST need to operate:

function example_services_resources() {
  $resources = array();
  $resources['einvoice'] = array(
    'actions' => array(
      'search' => array(
        'access callback' => '_example_resource_access',
        'callback'        => '_example_resource_search',
        'help'            => 'E-invoice online checker.',
        'file'            => array(
          'type'   => 'inc',
          'module' => 'exmaple',
          'name'   => 'resources/exmaple.resource',
        'args'            => array(
            'name'        => 'input',
            'optional'    => FALSE,
            'source'      => array('data' => 'input'),
            'type'        => 'string',
            'description' => 'Put the query string to get some data.',
  return $resources;

In example.resource.inc file, you need to put the functions which you just declare in the hook(example_services_resources) before:

function _example_resource_access() {
  return TRUE;

function _example_resource_search($input) {
  // To do something you want.

I hope this answer could make some help.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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