When creating a REST resource with hook_services_resources() and adding an action, the action is being overridden by retrieve and retrieve is taking my action as an argument.

<?php
function brain_api_services_resources() {
  return array(
    'brain' => array(	
      'retrieve' => array(
        'help' => 'Retrieves a user\'s brain',
        'callback' => 'brain_api_user_retrieve',
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'access arguments append' => false,
        'args' => array(
          array(
            'name' => 'uid',
            'type' => 'int',
            'description' => 'The user id of the brain to get',
            'source' => array('path' => '0'),
            'optional' => false,
            'default value' => NULL
          ),
        ),
      ), 
      'index' => array(
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'access arguments append' => false,
        'args' => array(),
        'help' => 'Retrieves brain memories',
        'callback' => 'brain_api_memories_index',
      ),
      'actions' => array(
        'memories' => array(
          'help' => 'Return memories object',
          'callback' => 'brain_api_memories',		
        ),
      )
    ),
  );
}

Comments

didlix’s picture

Issue summary: View changes

profile to brains

didlix’s picture

Issue summary: View changes

cleaner spacing

didlix’s picture

Having explored the code a little, I've noticed I was trying to access the wrong url as actions are mapped to controller/res/action/action_name

However, with that in mind, when accessing person.local/res/brain/action/memories I get 404 Not Found: Could not find the controller

didlix’s picture

Status: Active » Closed (works as designed)

Should be called via POST.

didlix’s picture

Issue summary: View changes

tidied up tabbing