0

I've been using the Services module with the REST module from quite some time now.

I want to make a single PUT application/json request with an appropriate JSON raw body for it, passing more than a resource ID, instead of making different requests. So far as I read, I found I can use PUT request: http://.../resource_endpoint/resouce_name/resource_id.

1
  • 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. Feb 10, 2015 at 15:03

1 Answer 1

0

Implement hook_services_resources().

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(
          array(
            'name'        => 'input',
            'optional'    => FALSE,
            'source'      => array('data' => 'input'),
            'type'        => 'string',
            'description' => 'Put the query string to get some data.',
          ),
        ),
      ),
    ),
  );
  return $resources;
}

In the example.resource.inc file, you put the functions declared in that hook.

function _example_resource_access() {
  return TRUE;
}

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

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.