2

On a Drupal6 installation I have the REST service enabled (6.x-3.3).

All seems to setup correctly, but I cannot query any data and get always 404 Not Found.

What is the correct URL for retieve node #1:

    http://local.host/rest/node/1
    http://local.host/services/rest/node/1

None of them returns any data.

$endpoint = new stdClass;
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'rest';
$endpoint->server = 'rest_server';
$endpoint->path = 'rest';
$endpoint->authentication = array();
$endpoint->server_settings = array(
  'rest_server' => array(
    'formatters' => array(
      'json' => TRUE,
      'bencode' => FALSE,
      'jsonp' => FALSE,
      'php' => FALSE,
      'rss' => FALSE,
      'xml' => FALSE,
      'yaml' => FALSE,
    ),
    'parsers' => array(
      'application/json' => TRUE,
      'application/vnd.php.serialized' => FALSE,
      'application/x-www-form-urlencoded' => FALSE,
      'application/x-yaml' => FALSE,
      'multipart/form-data' => FALSE,
    ),
  ),
);
$endpoint->resources = array(
  'node' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'create' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'relationships' => array(
      'files' => array(
        'enabled' => 1,
      ),
      'comments' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'system' => array(
    'actions' => array(
      'connect' => array(
        'enabled' => 1,
      ),
      'get_variable' => array(
        'enabled' => 1,
      ),
      'set_variable' => array(
        'enabled' => 1,
      ),
      'del_variable' => array(
        'enabled' => 1,
      ),
    ),
  ),
);
$endpoint->debug = 0;

Update

Get this running now:

1
$endpoint = new stdClass();
$endpoint->disabled = FALSE;
$endpoint->api_version = 3;
$endpoint->name = 'rest';
$endpoint->server = 'rest_server';
$endpoint->path = 'rest';
$endpoint->authentication = array();
$endpoint->server_settings = array(
  'rest_server' => array(
    'formatters' => array(
      'json' => TRUE,
      'bencode' => FALSE,
      'jsonp' => FALSE,
      'php' => FALSE,
      'rss' => FALSE,
      'xml' => FALSE,
      'yaml' => FALSE,
),
'parsers' => array(
  'application/json' => TRUE,
  'application/vnd.php.serialized' => FALSE,
  'application/x-www-form-urlencoded' => FALSE,
  'application/x-yaml' => FALSE,
  'multipart/form-data' => FALSE,
  ),
 ),
);
$endpoint->resources = array(
 'comment' => array(
  'operations' => array(
  'create' => array(
    'enabled' => '1',
  ),
  'retrieve' => array(
    'enabled' => '1',
  ),
  'update' => array(
    'enabled' => '1',
  ),
  'delete' => array(
    'enabled' => '1',
  ),
  'index' => array(
    'enabled' => '1',
  ),
),
'actions' => array(
  'countAll' => array(
    'enabled' => '1',
  ),
  'countNew' => array(
    'enabled' => '1',
  ),
),
  ),
'file' => array(
'operations' => array(
  'create' => array(
    'enabled' => '1',
  ),
  'retrieve' => array(
    'enabled' => '1',
  ),
  'delete' => array(
    'enabled' => '1',
  ),
  'index' => array(
    'enabled' => '1',
  ),
),
'actions' => array(
  'create_raw' => array(
    'enabled' => '1',
  ),
 ),
),
'node' => array(
'operations' => array(
  'retrieve' => array(
    'enabled' => '1',
  ),
  'create' => array(
    'enabled' => '1',
  ),
  'update' => array(
    'enabled' => '1',
  ),
  'delete' => array(
    'enabled' => '1',
  ),
  'index' => array(
    'enabled' => '1',
  ),
),
'relationships' => array(
  'files' => array(
    'enabled' => '1',
  ),
  'comments' => array(
    'enabled' => '1',
  ),
),
'targeted_actions' => array(
  'attach_file' => array(
    'enabled' => '1',
  ),
  ),
 ),
 'system' => array(
 'actions' => array(
  'connect' => array(
    'enabled' => '1',
  ),
  'get_variable' => array(
    'enabled' => '1',
  ),
  'set_variable' => array(
    'enabled' => '1',
  ),
  'del_variable' => array(
    'enabled' => '1',
  ),
 ),
 ),
 'taxonomy_term' => array(
'operations' => array(
  'retrieve' => array(
    'enabled' => '1',
  ),
  'create' => array(
    'enabled' => '1',
  ),
  'update' => array(
    'enabled' => '1',
  ),
  'delete' => array(
    'enabled' => '1',
  ),
  'index' => array(
    'enabled' => '1',
  ),
),
'actions' => array(
  'selectNodes' => array(
    'enabled' => '1',
  ),
),
),
'taxonomy_vocabulary' => array(
'operations' => array(
  'retrieve' => array(
    'enabled' => '1',
  ),
  'create' => array(
    'enabled' => '1',
  ),
  'update' => array(
    'enabled' => '1',
  ),
  'delete' => array(
    'enabled' => '1',
  ),
  'index' => array(
    'enabled' => '1',
  ),
),
'actions' => array(
  'getTree' => array(
    'enabled' => '1',
  ),
),
),
'user' => array(
'operations' => array(
  'retrieve' => array(
    'enabled' => '1',
  ),
  'create' => array(
    'enabled' => '1',
  ),
  'update' => array(
    'enabled' => '1',
  ),
  'delete' => array(
    'enabled' => '1',
  ),
  'index' => array(
    'enabled' => '1',
  ),
),
'actions' => array(
  'login' => array(
    'enabled' => '1',
  ),
  'logout' => array(
    'enabled' => '1',
    'settings' => array(
      'services' => array(
        'resource_api_version' => '1.0',
      ),
    ),
  ),
  'register' => array(
    'enabled' => '1',
  ),
 ),
),
);
$endpoint->debug = 0;

can you check with this code

1

Take a look at Services Installation and Setup

Also you can read Testing resources on a test server to dig deeper.

Adding a REST server

  • Browse to admin/build/services
  • Click on the Add tab
  • Set the name of you rest server for example rest_server
  • Select the REST to be the Server Type
  • Type the Path to endpoint, I set to rest_server_endpoint
  • Authentication to be Session authentication
  • Save
  • Switch to the Server tab and allow application/x-www-form-urlencoded as a request paring type
  • Switch to the resources tab and select the resources you need to manipulate with rest client for example if you need to login check on users-> login
  • Save
0

After successful installation of rest service, and setup the endpoint url. If you still getting the page not found error means, try to change the path to end point and try . it will work fine !

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.