Hello,

I want to make use of the system resource to make a get_variable. So, I made such requests:

request.open('GET','http://www.mydomain.com/myendpoint/system');
request.send('&method=get_variable');

request.open('GET','http://www.mydomain.com/myendpoint/system/get_variable');
request.send();

request.open('GET','http://www.mydomain.com/myendpoint/system');
request.send();

I always get "Could not find the controller"
What is the problem?

thank you,
casbar

Comments

kylebrowning’s picture

Status: Active » Closed (fixed)

request.open('GET','http://www.mydomain.com/myendpoint/system/get_variable');

probably needs to be
request.open('POST','http://www.mydomain.com/myendpoint/system/get_variable');

since get variable is an action

casbar’s picture

I already tried evertything! It simply doesn't work! I do not know why!!

Maybe someone knows the reason!?

casbar

revnoah’s picture

Did you ever solve this?

revnoah’s picture

Issue summary: View changes

path edits

lonalore’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

I have the same problem, I always get "Could not find the controller".

- REST server
- Endpoint: "api/v1"

Request URL: http://www.mydomain.com/api/v1/get/html

My implementation:


/**
 * Implements hook_services_resources().
 */
function cmp_services_services_resources() {
  return array(
    'get' => array(
      'operations' => array(
        'html' => array(
          'help'                    => 'Get the HTML sources of a website',
          'file'                    => array(
            'type'   => 'inc',
            'module' => 'cmp_services',
            'name'   => 'cmp_services.resources'
          ),
          'callback'                => 'cmp_services_get_html',
          'args'                    => array(
            array(
              'name'          => 'params',
              'optional'      => TRUE,
              'source'        => 'data',
              'type'          => 'array',
              'description'   => 'parameters',
              'default value' => array(),
            ),
          ),
          'access callback' => 'cmp_services_access_callback',
          // 'access arguments' => array('access content'),
          'access arguments append' => FALSE,
        ),
      ),
    ),
  );
}

/**
 * Access callback.
 */
function cmp_services_access_callback() {
  return TRUE;
}

and my callback:

/**
 * Callback function for service resource.
 */
function cmp_services_get_html($params = array()) {
  $data = array(
    'foo' => 'bar',
  );

  return $data;
}

What is the problem? :/

kylebrowning’s picture

Status: Active » Closed (fixed)

Hey Lona, based on your custom resource 'get' is not an available array index.

Try 'retrieve', and take a look at http://cgit.drupalcode.org/services/tree/docs/services.services.api.php?...