可以命中Drupal7REST资源端点,但不能添加CRUD操作



我有一个使用D7服务模块定义的REST端点。我已经启用了服务和CRUD操作。我已启用该权限。当我点击端点/myservice的url时,我会收到一条消息

Services Endpoint "myservice" has been setup successfully.

当我点击/myservice/create(这是我启用的CreateCRUD服务)时,我只得到一个空白页面,尽管下面的回调有一个print语句。

.模块

function myservice_permission() {
    return array('create constructs' => array(
      'title' => t('create constructs'),
      'description' => t('Receive messages'),
    )
  );
}
function _myservice_access($ops, $args) {
  return TRUE;
}
function myservice_services_resources() {
  return array(
    'myservice_messages' => array(
        'create' => array(
        'help' => 'Creates messages',
        'callback' => '_myservice_create',
        'access callback' => '_myservice_access',
        'access arguments' => array('create constructs'),
        'access arguments append' => FALSE,
           'args' => array(
                array(
                    'name' => 'data',
                    'type' => 'struct',
                    'description' => '',
                    'source' => 'data',
                    'optional' => TRUE,
                ),          
           ),
        ),
    );
}
function _mymodule_create($data) {
  print '***here';
}
function myservice_services_endpoint() {
  $endpoints = array();
  $endpoint = new stdClass();
  $endpoint->disabled = FALSE;
  $endpoint->api_version = 3;
  $endpoint->name = 'myservice';
  $endpoint->server = 'rest_server';
  $endpoint->path = 'myservice_message';
  $endpoint->authentication = array();
  $endpoint->server_settings = array();
  $endpoint->resources = array(
      'myservice' => array(
        'operations' => array(
            'create' => array(
                'enabled' => '1',
            ),
        ),
      ),
  );
  $endpoint->debug = 1;
  $endpoints[] = $endpoint;
  return $endpoints;
}

在服务管理面板中,我启用了资源和crud操作。

我应该问一个相关的问题:有4个命名项,端点、资源、服务和端点路径。所有人都必须有不同的名字吗?

这是我尝试测试的方式。我完全不知道我测试的是POST事务,而不是GET。

仅供参考,测试非GET事务的最简单方法是使用助手。对于chrome,我下载了Advanced Rest Client。实际上,将post数据发送到配置为处理post的服务是测试它的最佳方式:)

相关内容

最新更新