0

I have a web service with the Services module that works perfectly, with an URL like myweb.com\api\my_conent\124 I obtain the information of my_content that has the 124 id.

Now with the URL myweb.com\api\my_content I want to obtain all the contents of my_content, but it doesn't return anything, a blank page. I have the 'optional' => TRUE, for the arguments.

How can I use the web service with one or none arguments?

0

Do you have an 'index' operation? Take a look at the services.services.api.php file in services module, docs folder.

In the node resource, you have several different 'operations' ( retrieve, create, update & index, .. ). Here's the snippet you should look at:

$node_resource = array(
    'node' => array(
      'operations' => array(
        ..
        'index' => array(
          'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'),
          'callback' => '_node_resource_index',
          ..
        ),
      ),
    ),
  );
  return $node_resource;

GET request to endpoint + resource will trigger 'index'. Read more about it here https://drupal.org/node/783254

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.