I still can't obtain anything from REST server.

Let's say I want to work with node. Under Drupal admin all the 4 services works fine :

  • node.get
  • node.view
  • node.save
  • node.delete

But when I try the same request from outside Drupal nothing happen. Examining HTTP request show an error in response : 404 Not found: could not find resource

Trying to test REST server via my_url/services/rest lead to the same 404 error.
In the same times XML-RPC server test request lead to a 200 response with following content : "XML-RPC server accepts POST requests only".

Both services and REST server was updated one hour ago (6.x-2.x-dev (2009-sept.-06) and 6.x-2.0-beta-1)

May I have missed something ?

CommentFileSizeAuthor
#66 1.png91.85 KBedup_pt
#66 2.png70.51 KBedup_pt
#66 3.png72.36 KBedup_pt
#66 home.png68.58 KBedup_pt
#66 error_0.png42.31 KBedup_pt
#66 error_2.png42.86 KBedup_pt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

leovarg’s picture

same exact thing here . anyone?

librarywebchic’s picture

I'm seeing the exact same error with the REST Server. Has anyone figured out what is going on or how to solve this?

leovarg’s picture

Nop, i dont think so! I'm still looking for that to be fix

Anonymous’s picture

As for me I did not try again : I've put the functionnality using it on an hold state.

Hugo Wetterberg’s picture

Hi Guys,
Sorry about the delay with this, I wasn't subscribed to the issue queue. What are your respective setups. Enabled services, the url's you tried to access, and so on?

/Hugo

Anonymous’s picture

Hi Hugo,

The project involving REST server is in pending state and every stuff have been archived.

The customer I am working for plan to reactivate this part of it's project by the end of November. I then can give you all the informations needed.

gmartens’s picture

Hi

I'm using Drupal 6.11 with

REST SERVER module: 6.x-2.0-beta1
SERVICES module: 6.x-2.x-dev

a simple HTTP-get via my_url/services/rest/node/123 also causes the 404-error:

HTTP/1.0 404 Not found: could not find resource

So a fix for this issue would be great!
Greetz,

GM

Hugo Wetterberg’s picture

Ok, just to check, have you enabled the node_resource module? Not just the node_service module?
/Hugo

gmartens’s picture

Hugo,

yes both node resource and node service modules are enabled ....

GM

kehan’s picture

I'm getting the same problem (404s) using the urls in the readme file with the node_resource, services, rest_server. Do we need some services authentication modules enabled?
wget http://localhost/services/rest/node/28
returns:

HTTP request sent, awaiting response... 404 Not found: could not find controller
2009-11-27 17:00:47 ERROR 404: Not found: could not find controller.
lasconic’s picture

Assigned: Hugo Wetterberg » Unassigned
Category: bug » support
Status: Needs review » Active

I think rest_server needs to be adjusted to work with the last version (6.x-2.x-dev) of services.
In particular because of this issue #616490: Services API misuses hash/number (#) symbols

Hugo Wetterberg’s picture

Ok, I think that I've pinpointed the problem. Most of you guys are probably running drupal in a subdirectory, which I've never done, and there are some faulty path manipulation that's done when the base path is anything else than /.

There is also some problems with the recent change that started stripping #s from all service declarations.

A update is coming soon that will correct this. I'll try to get this done tonight.

Hugo Wetterberg’s picture

Assigned: Unassigned » Hugo Wetterberg
Category: support » bug
Hugo Wetterberg’s picture

Status: Active » Fixed

Tagged a 6.x-2.0-beta2 release of REST Server with the following changes:
http://github.com/hugowetterberg/rest_server/commit/413a1640acf673aa48e4...

(http://drupal.org/cvs?commit=294780)

pm530’s picture

Hi Hugo:

Looks like the problem is still there in 6.x-2.0-beta2. I am using it with Service 6.x-2.x-dev and drupal's multisite.

pm530’s picture

Status: Fixed » Needs review

Hi Hugo:

Looks like the problem is still there in 6.x-2.0-beta2. I am using it with Service 6.x-2.x-dev and drupal's multisite.

Hugo Wetterberg’s picture

Have you installed and configured a authentication module?

pm530’s picture

Hi Hugo:

The key authentication module is installed and configured. 404 error is still there.

FYI:
the git diff shows a change in RESTserver.inc:

- $cm = $controller['#models'][$formatter['model']];
+ $cm = $controller['models'][$formatter['model']];

but the change is not in beta2 release.

And this doesn't make it work.

Hugo Wetterberg’s picture

What's the 404 status message?

pm530’s picture

HTTP/1.x 404 Not found: could not find resource

Hugo Wetterberg’s picture

And the node_resource is installed and the url you're trying to access is: "http://example.com/services/rest/node"?

Can you check what $canonical_path is at line 14 in RESTServer.inc and what $resources and $resource_name is before the if statement at line 49?

pm530’s picture

Hi Hugo:

I found my problem. I forget to enable the node_resource module. Sorry for the false alarm.

The new question is. How can I user this module to serve other services. Let's say system.connect .

kehan’s picture

Hi Hugo,
I get the following values:
$canonical_path = 'node/28' (I'm trying to load node 28)
$resource_name = 'node'
$resources:

array (
  'service_node' => 
  array (
    'actions' => 
    array (
      'get' => 
      array (
        'method' => 'node.get',
        'callback' => 'node_service_get',
        'access callback' => 'node_service_get_access',
        'file' => 
        array (
          'file' => 'inc',
          'module' => 'node_service',
        ),
        'args' => 
        array (
          0 => 
          array (
            'name' => 'hash',
            'type' => 'string',
            'description' => 'A valid API key.',
            'source' => 
            array (
              'data' => 'hash',
            ),
          ),
          1 => 
          array (
            'name' => 'domain_name',
            'type' => 'string',
            'description' => 'A valid domain for the API key.',
            'source' => 
            array (
              'data' => 'domain_name',
            ),
          ),
          2 => 
          array (
            'name' => 'domain_time_stamp',
            'type' => 'string',
            'description' => 'Time stamp used to hash key.',
            'source' => 
            array (
              'data' => 'domain_time_stamp',
            ),
          ),
          3 => 
          array (
            'name' => 'nonce',
            'type' => 'string',
            'description' => 'One time use nonce also used hash key.',
            'source' => 
            array (
              'data' => 'nonce',
            ),
          ),
          4 => 
          array (
            'name' => 'nid',
            'type' => 'int',
            'description' => 'A node ID.',
            'optional' => false,
            'source' => 
            array (
              'data' => 'nid',
            ),
          ),
          5 => 
          array (
            'name' => 'fields',
            'type' => 'array',
            'optional' => true,
            'description' => 'A list of fields to return.',
            'source' => 
            array (
              'data' => 'fields',
            ),
          ),
        ),
        'return' => 'struct',
        'help' => 'Returns a node data.',
        'key' => true,
        'auth' => true,
      ),
      'view' => 
      array (
        'method' => 'node.view',
        'callback' => 'node_service_view',
        'access callback' => 'node_service_view_access',
        'file' => 
        array (
          'file' => 'inc',
          'module' => 'node_service',
        ),
        'args' => 
        array (
          0 => 
          array (
            'name' => 'hash',
            'type' => 'string',
            'description' => 'A valid API key.',
            'source' => 
            array (
              'data' => 'hash',
            ),
          ),
          1 => 
          array (
            'name' => 'domain_name',
            'type' => 'string',
            'description' => 'A valid domain for the API key.',
            'source' => 
            array (
              'data' => 'domain_name',
            ),
          ),
          2 => 
          array (
            'name' => 'domain_time_stamp',
            'type' => 'string',
            'description' => 'Time stamp used to hash key.',
            'source' => 
            array (
              'data' => 'domain_time_stamp',
            ),
          ),
          3 => 
          array (
            'name' => 'nonce',
            'type' => 'string',
            'description' => 'One time use nonce also used hash key.',
            'source' => 
            array (
              'data' => 'nonce',
            ),
          ),
          4 => 
          array (
            'name' => 'nid',
            'type' => 'int',
            'description' => 'A node id.',
            'optional' => false,
            'source' => 
            array (
              'data' => 'nid',
            ),
          ),
          5 => 
          array (
            'name' => 'fields',
            'type' => 'array',
            'optional' => true,
            'description' => 'A list of fields to return.',
            'source' => 
            array (
              'data' => 'fields',
            ),
          ),
          6 => 
          array (
            'name' => 'teaser',
            'type' => 'boolean',
            'optional' => true,
            'description' => 'Is this a teaser version of the node?',
            'source' => 
            array (
              'data' => 'teaser',
            ),
          ),
          7 => 
          array (
            'name' => 'page',
            'type' => 'boolean',
            'optional' => true,
            'description' => 'Is this a page version of the node?',
            'source' => 
            array (
              'data' => 'page',
            ),
          ),
        ),
        'return' => 'struct',
        'help' => 'Returns a node data.',
        'key' => true,
        'auth' => true,
      ),
      'save' => 
      array (
        'method' => 'node.save',
        'callback' => 'node_service_save',
        'access callback' => 'node_service_save_access',
        'file' => 
        array (
          'file' => 'inc',
          'module' => 'node_service',
        ),
        'args' => 
        array (
          0 => 
          array (
            'name' => 'hash',
            'type' => 'string',
            'description' => 'A valid API key.',
            'source' => 
            array (
              'data' => 'hash',
            ),
          ),
          1 => 
          array (
            'name' => 'domain_name',
            'type' => 'string',
            'description' => 'A valid domain for the API key.',
            'source' => 
            array (
              'data' => 'domain_name',
            ),
          ),
          2 => 
          array (
            'name' => 'domain_time_stamp',
            'type' => 'string',
            'description' => 'Time stamp used to hash key.',
            'source' => 
            array (
              'data' => 'domain_time_stamp',
            ),
          ),
          3 => 
          array (
            'name' => 'nonce',
            'type' => 'string',
            'description' => 'One time use nonce also used hash key.',
            'source' => 
            array (
              'data' => 'nonce',
            ),
          ),
          4 => 
          array (
            'name' => 'node',
            'type' => 'struct',
            'description' => 'A node object. Upon creation, node object must include "type". Upon update, node object must include "nid" and "changed".',
            'optional' => false,
            'source' => 
            array (
              'data' => 'node',
            ),
          ),
        ),
        'return' => 'struct',
        'help' => 'Save a node object into the database.',
        'key' => true,
        'auth' => true,
      ),
      'delete' => 
      array (
        'method' => 'node.delete',
        'callback' => 'node_delete',
        'access callback' => 'node_service_delete_access',
        'file' => 
        array (
          'file' => 'inc',
          'module' => 'node_service',
        ),
        'args' => 
        array (
          0 => 
          array (
            'name' => 'hash',
            'type' => 'string',
            'description' => 'A valid API key.',
            'source' => 
            array (
              'data' => 'hash',
            ),
          ),
          1 => 
          array (
            'name' => 'domain_name',
            'type' => 'string',
            'description' => 'A valid domain for the API key.',
            'source' => 
            array (
              'data' => 'domain_name',
            ),
          ),
          2 => 
          array (
            'name' => 'domain_time_stamp',
            'type' => 'string',
            'description' => 'Time stamp used to hash key.',
            'source' => 
            array (
              'data' => 'domain_time_stamp',
            ),
          ),
          3 => 
          array (
            'name' => 'nonce',
            'type' => 'string',
            'description' => 'One time use nonce also used hash key.',
            'source' => 
            array (
              'data' => 'nonce',
            ),
          ),
          4 => 
          array (
            'name' => 'nid',
            'type' => 'int',
            'description' => 'A node ID.',
            'optional' => false,
            'source' => 
            array (
              'data' => 'nid',
            ),
          ),
        ),
        'help' => 'Delete a node.',
        'key' => true,
        'auth' => true,
      ),
    ),
  ),
  'node' => 
  array (
    'file' => 
    array (
      'file' => 'inc',
      'module' => 'node_resource',
    ),
    'retrieve' => 
    array (
      'callback' => '_node_resource_retrieve',
      'args' => 
      array (
        0 => 
        array (
          'name' => 'hash',
          'type' => 'string',
          'description' => 'A valid API key.',
        ),
        1 => 
        array (
          'name' => 'domain_name',
          'type' => 'string',
          'description' => 'A valid domain for the API key.',
        ),
        2 => 
        array (
          'name' => 'domain_time_stamp',
          'type' => 'string',
          'description' => 'Time stamp used to hash key.',
        ),
        3 => 
        array (
          'name' => 'nonce',
          'type' => 'string',
          'description' => 'One time use nonce also used hash key.',
        ),
        4 => 
        array (
          'name' => 'nid',
          'optional' => false,
          'source' => 
          array (
            'path' => 0,
          ),
          'type' => 'int',
          'description' => 'The nid of the node to get',
        ),
      ),
      'models' => 
      array (
        'ResourceFeedModel' => 
        array (
          'class' => 'NodeResourceFeedModel',
          'arguments' => 
          array (
            'source' => 'single',
          ),
        ),
      ),
      'access callback' => '_node_resource_access',
      'access arguments' => 
      array (
        0 => 'view',
      ),
      'access arguments append' => true,
      'auth' => true,
      'key' => true,
    ),
    'create' => 
    array (
      'callback' => '_node_resource_create',
      'args' => 
      array (
        0 => 
        array (
          'name' => 'hash',
          'type' => 'string',
          'description' => 'A valid API key.',
        ),
        1 => 
        array (
          'name' => 'domain_name',
          'type' => 'string',
          'description' => 'A valid domain for the API key.',
        ),
        2 => 
        array (
          'name' => 'domain_time_stamp',
          'type' => 'string',
          'description' => 'Time stamp used to hash key.',
        ),
        3 => 
        array (
          'name' => 'nonce',
          'type' => 'string',
          'description' => 'One time use nonce also used hash key.',
        ),
        4 => 
        array (
          'name' => 'node',
          'optional' => false,
          'source' => 'data',
          'description' => 'The node object to create',
          'type' => 'struct',
        ),
      ),
      'access callback' => '_node_resource_access',
      'access arguments' => 
      array (
        0 => 'create',
      ),
      'access arguments append' => true,
      'auth' => true,
      'key' => true,
    ),
    'update' => 
    array (
      'callback' => '_node_resource_update',
      'args' => 
      array (
        0 => 
        array (
          'name' => 'hash',
          'type' => 'string',
          'description' => 'A valid API key.',
        ),
        1 => 
        array (
          'name' => 'domain_name',
          'type' => 'string',
          'description' => 'A valid domain for the API key.',
        ),
        2 => 
        array (
          'name' => 'domain_time_stamp',
          'type' => 'string',
          'description' => 'Time stamp used to hash key.',
        ),
        3 => 
        array (
          'name' => 'nonce',
          'type' => 'string',
          'description' => 'One time use nonce also used hash key.',
        ),
        4 => 
        array (
          'name' => 'node',
          'optional' => false,
          'source' => 'data',
          'description' => 'The node data to update',
          'type' => 'struct',
        ),
      ),
      'access callback' => '_node_resource_access',
      'access arguments' => 
      array (
        0 => 'update',
      ),
      'access arguments append' => true,
      'auth' => true,
      'key' => true,
    ),
    'delete' => 
    array (
      'callback' => '_node_resource_delete',
      'args' => 
      array (
        0 => 
        array (
          'name' => 'hash',
          'type' => 'string',
          'description' => 'A valid API key.',
        ),
        1 => 
        array (
          'name' => 'domain_name',
          'type' => 'string',
          'description' => 'A valid domain for the API key.',
        ),
        2 => 
        array (
          'name' => 'domain_time_stamp',
          'type' => 'string',
          'description' => 'Time stamp used to hash key.',
        ),
        3 => 
        array (
          'name' => 'nonce',
          'type' => 'string',
          'description' => 'One time use nonce also used hash key.',
        ),
        4 => 
        array (
          'name' => 'nid',
          'optional' => false,
          'source' => 
          array (
            'path' => 0,
          ),
        ),
      ),
      'access callback' => '_node_resource_access',
      'access arguments' => 
      array (
        0 => 'delete',
      ),
      'access arguments append' => true,
      'auth' => true,
      'key' => true,
    ),
    'index' => 
    array (
      'callback' => '_node_resource_index',
      'args' => 
      array (
        0 => 
        array (
          'name' => 'hash',
          'type' => 'string',
          'description' => 'A valid API key.',
        ),
        1 => 
        array (
          'name' => 'domain_name',
          'type' => 'string',
          'description' => 'A valid domain for the API key.',
        ),
        2 => 
        array (
          'name' => 'domain_time_stamp',
          'type' => 'string',
          'description' => 'Time stamp used to hash key.',
        ),
        3 => 
        array (
          'name' => 'nonce',
          'type' => 'string',
          'description' => 'One time use nonce also used hash key.',
        ),
        4 => 
        array (
          'name' => 'page',
          'optional' => true,
          'type' => 'int',
          'description' => 'The zero-based index of the page to get, defaults to 0.',
          'default value' => 0,
          'source' => 
          array (
            'param' => 'page',
          ),
        ),
        5 => 
        array (
          'name' => 'fields',
          'optional' => true,
          'type' => 'string',
          'description' => 'The fields to get.',
          'default value' => '',
          'source' => 
          array (
            'param' => 'fields',
          ),
        ),
        6 => 
        array (
          'name' => 'parameters',
          'optional' => true,
          'type' => 'struct',
          'description' => 'Parameters',
          'default value' => NULL,
          'source' => 'param',
        ),
      ),
      'models' => 
      array (
        'ResourceFeedModel' => 
        array (
          'class' => 'NodeResourceFeedModel',
        ),
        'ResourceTimeFeedModel' => 
        array (
          'class' => 'NodeResourceFeedModel',
        ),
      ),
      'access arguments' => 
      array (
        0 => 'access content',
      ),
      'access arguments append' => true,
      'access callback' => 'services_access_menu',
      'auth' => true,
      'key' => true,
    ),
    'name' => 'node',
  ),
)

I have key based authentication module enabled but have then unchecked the 'use keys' option on admin>build>services.
I'm am using a multisite install, with the modules in my specific site's folder.
wget is still giving me 404:

wget http://vocabularies.gbif.dev/services/rest/node/28
--2009-11-30 13:24:40--  http://vocabularies.gbif.dev/services/rest/node/28
Resolving vocabularies.gbif.dev... 157.140.4.78
Connecting to vocabularies.gbif.dev|157.140.4.78|:80... connected.
HTTP request sent, awaiting response... 404 Not found: could not find controller
2009-11-30 13:24:40 ERROR 404: Not found: could not find controller.

Thought I'd better post this but I'm looking into it.

kehan’s picture

OK I discovered a few stray hashes in includes/RESTServer.inc - on double checking these have been removed in the version at http://github.com/hugowetterberg/rest_server - could you commit this code to cvs.drupal.org as the dev snapshot is broken with the latest services module.

Thanks,
Kehan

gmartens’s picture

hi Kehan,

I tested your latest version (http://github.com/hugowetterberg/rest_server), but I'm
still having the same issue ...

> wget http://localhost/drupal/services/rest/node/138
--11:02:54-- http://localhost:80/drupal/services/rest/node/138
=> `138'
Connecting to localhost:80... connected!
HTTP request sent, awaiting response... 404 Not found: could not find resource
11:02:56 ERROR 404: Not found: could not find resource.

The node service & node resource, key authentication module (but also unchecked the 'use keys' ) are enabled.
Drupal is in a subfolder since I'm using a multisite install
greets,
GM

myktra’s picture

Same here, Drupal in subfolder off webroot, returning a 404. Also having a similar problem (perhaps) with the JSON server module.

ransomweaver’s picture

Is the WSOD when visiting mysite.com/services/rest indicative of rest_server FAIL? version 1 didn't do this.

And anyone have any node.save php cURL examples? everything I do comes back http 500, internal server error. Though hopefully that's due to line 1 above....

lasconic’s picture

Assigned: Unassigned » Hugo Wetterberg
Category: support » bug
Status: Active » Needs review

Could this be commited to 6.2 branch?

Hugo Wetterberg’s picture

Version: 6.x-2.0-beta1 » 6.x-2.0-beta3

Hi everybody. I've committed the missing hash removal as beta3. And the subfolder issue should be resolved since beta2.

@ransomweaver No it's not indicative of a fail, there's simply nothing to show at the root, if a resource has a index controller the next level, in other words: mysite.com/services/rest/node will give you some results.

When I'm testing things through everything seems to work. So what I need to know is: using the latest and greatest version of services and rest_server, do you still have problems?

Cheers,
Hugo

Hugo Wetterberg’s picture

Status: Needs review » Postponed (maintainer needs more info)
arirasekh’s picture

I appear to be having the same issue.

I'm using the services 6.x-2.0-beta1 with rest_server-6.x-2.0-beta3. I've got Drupal running in a subdirectory within web root and I receive a 404 error with any of the following requests (regardless of clean URLs being enabled/disabled):

http://localhost/drupal-6.6/?q=services/rest
http://localhost/drupal-6.6/?q=services/rest&method=node.get&nid=1
http://localhost/drupal-6.6/?q=services/rest&method=node.load&nid=1

Thanks

Hugo Wetterberg’s picture

@arirasekh That's because the REST server doesn't work like that. Check out the notes for the 2.x version on the project page, I've moved them to the top of the page so that less people will miss them. And you also seem to have installed the node service and not the node resource, which sort of takes away some of the benefits of the REST server.

blaupunkt72’s picture

Version: 6.x-2.0-beta3 » 6.x-2.0-beta2
Component: Miscellaneous » Documentation
Category: bug » task
Status: Postponed (maintainer needs more info) » Needs review

It would be helpful to include some additional samples across the different services.

the included 'retrieve' sample, http://[server]/services/rest/node works great to get a giant dump with no details

GET /services/rest/node?type=xxxx does not query as the docs suggest is the case for index pages

one of the entries suggests using views to filter records, but it is unclear what the REST syntax is for the View Service

the intuitive GET /services/rest/view does not work

Hugo Wetterberg’s picture

Version: 6.x-2.0-beta2 » 6.x-2.0-beta3
Status: Needs review » Active

Yes, this is pretty much a issue of lacking documentation. The node resource _can_ use my query_builder module for the node index, but I didn't want to introduce a dependency. Take a look at node_resource.inc, line 97: http://bit.ly/9s5B1x

The services that are written for rpc style servers are mapped to actions. 'views.get' will get mapped as the action 'get' on the resource 'service_views'. So the way to access it would be:

POST /services/rest/service_view/get

with the body:

{'view_name':'your_view','args':[1,34]}

/Hugo

ygerasimov’s picture

Dear Hugo,

I still have the same problem on my fresh drupal 6.15 installation. I use following versions of modules:
Services 6.x-2.0-beta1
Node Resource 6.x-2.0-beta1
Node Service 6.x-2.0-beta1

REST Server 6.x-2.0-beta3

But still when try to go example.com/services/rest/node or example.com/services/rest/node/1 get 404 Not found: could not find resource.

Let me know how to cope with this problem?

Thank you.

ygerasimov’s picture

sorry. everything is working after authentification keys has been created

geekomono’s picture

Category: task » support

Dear Hugo,

I have also the 404 Error.

I use the following modules :
+ Services 6.x-2.0-beta1
+ Node Resource 6.x-2.0-beta1
+ Node Service 6.x-2.0-beta1
+ REST Server 6.x-2.0-beta3
+ Zend framework

My test URL is http://127.0.0.1/drupal02/services/rest/node/1 and the drupal's version is 6.15.

I have not Authentification key and I'am learning how to use it. Maybe it is the solution as for ygerasimov. I do not realize specials configurations. I just installed the Services, REST Server and activated all modules. But I still have the error and I do not understand why ? Do you have an idea ?

Thank you .

kaw3939’s picture

Hi,

I am able to get the services module to retrieve a node, but I can't get it to retrieve a view.

I have tried a lot of different formats for the URL and none seems to work, this is my best guess as to what it is supposed to be:

/services/rest/service_view/get?view_name=workshop_section_template

My site is in a subdirectory, but retrieving a node works fine, so I think it is the syntax of my URI request. The view name is correct and it works in the services admin browse area correctly.

Thank you for any help,

kaw3939

joblo’s picture

I had a similar problem with REST:

+ installed and activated Services-6.x-2.0 / Node Resource / Node Service / REST Server 6.x-2.0-beta3
the test url in the browser didn't deliver a result: /services/rest/node/1
if have tried with services_keyauth disabled or not configured

the problem I have found:
+ the Service module behind the REST Service always want an authentication, even if no one is installed
+ the default attributes of the controller are always set to 'auth' => true

services.module: line 404

// Check authentication
  if ($method['auth'] && $auth_error = services_auth_invoke('authenticate_call', $method, $method_name, $args)) {
    if ($browsing) {
      drupal_set_message(t('Authentication failed: !message', array('!message' => $auth_error)), 'error');
    }
    else {
      return services_error($auth_error, 401);
    }
  }

and the function services_auth_invoke always returns true (means $auth_error) if no auth-method is found

function services_auth_invoke($method, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL) {
  $module = variable_get('services_auth_module', '');
  // Get information about the current auth module
  $func = services_auth_info($method, $module);
  if ($func) {
    if ($file = services_auth_info('file')) {
      ...
  }
  else{
    return TRUE; //<---------------  should return false ???
  }
}

changed return TRUE; to return FALSE; in line 326 and the REST service was accessable via the browser.
should the services_auth_invoke really return an error, if no auth method is found?

----------------------------------------
other side-effects with this change ??
----------------------------------------

another workaround I have tested
added
'#auth' => false,
'#key' => false,

in node_resource_service_resource in node_ressource.module (line 42)
+ but I think thats dangerous, because auth will always be generally disabled for retrieving nodes
+ should be set for own custom services only

sumitk’s picture

Confirming 39 .. and thanks joblo!
* rest_server beta3 + drupal 6.16 + services 2.x + no authentication method enabled is giving a 401 (authentication error) on services/rest/node
* Making change to line 326 to return a FLASE in services.module is making REST server work properly

ben.mi’s picture

Have a question.who can help me?
------
drupal 6.16
services 6.x-2.0
rest_server 6.x-2.0-beta3
Input stream helper 6.x-1.0
Autoload 6.x-1.3

all the module is opened.

but i can't get the result by http://services/services/rest/node/id

and the next code is return Failed to open/read local data from file/application.

$url = "http://services/services/rest";
$domain = 'services';
$timestamp = (string)time();
$nonce = user_password();
$hash = hash_hmac('sha256', $timestamp .';'.$domain .';'. $nonce .';'.'user.get', '4c17965ebb996d393cd77886e0f599e9', FALSE);
$url .= "/method=user.get&id=1&hash=" . $hash;
$url .= "&domain_name=".$domain;
$url .= "&domain_time_stamp=".$timestamp;
$url .= "&nonce=" . $nonce;
$session = curl_init($url);
echo $url;
curl_setopt($session, CURLOPT_POST, TRUE); // Do a regular HTTP POST
curl_setopt($session, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($session, CURLOPT_HEADER, FALSE);
curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($session);
$error = curl_error($session);
curl_close($session);
if (!empty($error)) {
  print '<pre>'.$error.'</pre>';
}
else {
  print '<pre>'.$result.'</pre>';
}

i don't konw why?

Hugo Wetterberg’s picture

I don't know anything about the key auth stuff. But this is how a request is made:

<?php

$url = "http://rest2x.hugo/services/rest/service_menu/get";
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, TRUE); // Do a regular HTTP POST
curl_setopt($handle, CURLOPT_HEADER, FALSE);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_HTTPHEADER, array(
  'Content-type: application/vnd.php.serialized',
  'Accept: application/vnd.php.serialized',
));
curl_setopt($handle, CURLOPT_POSTFIELDS, serialize(array(
  'menu_id' => 'primary-links',
  'fields' => array('link_path', 'link_title'),
)));

$result = curl_exec($handle);

var_dump(unserialize($result));

$error = curl_error($handle);
curl_close($handle);
if (!empty($error)) {
  print '<pre>'.$error.'</pre>';
}

?>

Or, if you use http_client:

<?php
$endpoint = 'http://rest2x.hugo/services/rest';
$client = new HttpClient(NULL, new HttpClientBaseFormatter());

try {
  $result = $client->post($endpoint . '/service_menu/get', array(
    'menu_id' => 'primary-links',
    'fields' => array('link_path', 'link_title'),
  ));
  var_dump($result);
}
catch (Exception $e) {
  print $e->getMessage();
}
?>
Josephnewyork’s picture

I can't get any requests to return anything (REST Server 2.0/Services 2.0).

I don't want to use Keys or session IDs, I just want to be able to load content via GET method...

When I visit these URLs in my browser, I'm expecting to see the REST XML, but I see nothing:
/services/rest/service_view/get?view_name=friends_service&args=joe (to load a view)
/services/rest/node/2 (to load a node)

I just want to be able to access some XML?? I can't think of anything else to try... Please help! Thanks!!

Hugo Wetterberg’s picture

You have to configure a authentication module. If you don't want one you'll have to install key auth and just uncheck all it's options. Stupid, I know, it's a services design/security choice that one may or may not agree with.

Other than that you'll have to learn to debug http requests. Look at response headers et cetera. The views example you posted will never work, as requests to translated (old-style) services have to be made using POST. The REST server will respond with a 404 controller not found when you make a call like that.

Also read up on what a REST server _is_, as that will help you understand how to use this module.

Josephnewyork’s picture

Thanks for the response Hugo.

I had it set up without checking the key or sessid, and no dice. Here is my response headers for /services/rest/node/2:

HTTP/1.0 404 Not found: could not find resource
Date: Wed, 12 May 2010 19:07:33 GMT
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.6
X-Powered-By: PHP/5.2.6
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Wed, 12 May 2010 19:07:33 GMT
Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0
Vary: Accept
Content-Length: 0
Connection: close
Content-Type: text/html; charset=utf-8

As to the views service, the need for the GET method instead of the POST is needed for CDN caching reasons. Actually, the reason I used it in the first place was because of the GET method... I'll have to create a work-around.

Thanks

maykelmoya’s picture

node.get allows a second argument for filtering fields. Is that doable with rest_server?

Thanks

wils.solutions’s picture

So,

My auth module is unchecked however I am getting the same error: 404 =(

tkx

wils.solutions’s picture

Hi Hugo,

I have followed the steps:

1 - Installed Services
2 - Installed the REST Server
3 - Enabled the Auth Key Module
4 - Created a Key
5 - On Key settigns i have disabled the key/sid checkboxes...all checkboxes are un checked.
6 - Still have the 404 page trying on my browser: /services/rest/node/1

Note: the all services are enabled.

Tkx
Wils

thbnelson’s picture

Apparently I made a work around for the issue described by joeweitzel. I wanted to use a simple GET request for CDN caching, simplicity and to test via browser. Just submitted as a bug on its own with a patch for beta3.

http://drupal.org/node/825412

iTiZZiMO’s picture

Title: Can't make REST server works » Can't make REST server works - 406 error

Hello all,!

i've the same issue.

Service Module 6.2
Rest_Server 6.2.x beta 03
All Services are activated
Node Creation of type xy allowed for anonymous user
Key Authentication Module enabled
Keys are created for all services

Here is my test script (i tried it with php.serialized and json format, always the same error 406

<?php
/*
* Service calls using API keys require four parameters:
*
*Timestamp - Current time in Unix timestamp format.
*Domain - The value you entered for domain above.
*Nonce - A random value.
*Hash - An sha256 hash of the timestamp, domain, nonce and remote method name delimited by semicolons and using the remote API key as the shared key.
*/
$url = "http://xxx.xx/services/rest/node/";
$domain = 'domain.de'; // only for security
$key = 'mykey'; // special key for application, see http://domain.de/admin/build/services/keys
$timestamp = (string)time();
$nonce = 'ZhzpW2okri'; // random 10 digit alphanumeric string for the $nonce
// generate security has 
$hash = hash_hmac('sha256', $timestamp .';'.$domain .';'. $nonce .';'.'node.save', $key, FALSE);
$getdata .= "?hash=" .$hash;
$getdata .= "&domain_name=".$domain;
$getdata .= "&domain_time_stamp=".$timestamp;
$getdata .= "&nonce=" . $nonce;
//$nodedata =  array { "type" : "sms", "title" : "test", "body" : "smstext" } '; // json format
$nodedata = array("type" => "page", "title" => "test", "body" => "test");
$session = curl_init($url.$getdata);
echo $url;
curl_setopt($session, CURLOPT_POST, TRUE); // Do a regular HTTP POST
curl_setopt($session, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($session, CURLOPT_HEADER, array('Content-type: application/vnd.php.serialized'));
curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
// build post data in json form
curl_setopt($session, CURLOPT_POSTFIELDS, serialize($nodedata));
$result = curl_exec($session);
$error = curl_error($session);
curl_close($session);
if (!empty($error)) {
  print '<pre>'.$error.'</pre>';
}
else {
  print '<pre>'.$result.'</pre>';
}
?>

Could anybody help me? it is also possible to send data for node creation via json format ?

iTiZZiMO’s picture

hello again,

i found out that the hash argument is missing?

here is the coding part of restserver.inc

   // When argument isn't set, insert default value if provided or
        // throw a exception if the argument isn't optional.
        if (!isset($arguments[$i])) {
          if (isset($info['default value'])) 

            $arguments[$i] = $info['default value'];
          }
          else if (!isset($info['optional']) || !$info['optional']) {
            watchdog('Rest API', 'Missing required argument !arg', array('!arg'=>$info['name']));
            throw new Exception(t('Missing required argument !arg', array('!arg'=>$info['name'])));
          }
        }
      }

if i disable use keys in the key authentication modules, it works.
Is it an issue of restserver or the key module?
Because the execption was thrown in rest_server module.

avner’s picture

i have the same problem
disabling the key did not resolve the issue

roynilanjan’s picture

when try to run like domain_name/services/rest/node/[nid] entire blank page is coming
i have used the beta3 version

roynilanjan’s picture

Can you explain what should be proper configuration with authentication module for this rest-server.... ?

dbosen’s picture

I had the same problem to get /services/rest/node/1. All I got was a blank page (just like roynilanjan).
But /services/rest/node/1.yaml or /services/rest/node/1.php etc. worked. My problem was, that my PHP did not have libxml2 included. After adding libxml2 support to php everything worked. Maybe some of you have a similar problem, just check if http://your_domain/services/rest/node/1.yaml works.

Openlogic’s picture

I was able to get the node.get and node.delete methods working as expected using the GET and DELETE http methods

What is the URL syntax to invoke methods such as node.view which do not have corresponding http methods? Would this be treated as a targeted action as described in the documentation on the project home page? If so, then I thought I'd try something like this:
POST /services/rest/node/123/view
but this results in a 404 "could not find controller"

Any clarification would be much appreciated.

Thanks

Faisal

deeptiengg’s picture

Hi,

I am using

REST Server - 6.x-2.0-beta3
Services - 6.x-2.2

I had few static nodes in my drupal application which I accessed from remote Rails based application using REST services as follows:

http://mysite/services/rest/node/2.json (2 is the node id of the drupal node)

Everything worked fine. Now I have some dynamic pages with PHP code in drupal which I again want to access from my remote application. So I used the same thing as above but I am not getting the dynamic content at the other end. Reason being that it uses node.get method which gives the copy of node so its returning the php code as it is. How this can be resolved..????? I have seen that node.view in drupal gives me the correct results, Is it possible to remotely access the node using node.view or if there is some other solution ????

Thanks for your help in advance.

Regards
deeptiengg

deeptiengg’s picture

Can someone suggest something please.....

J-Chance’s picture

subscribing

FreddieK’s picture

subscribing

ngstigator’s picture

Re #42

"Not found: could not find resource" when using the http_client version. When using the curl example I get "bool (false)".

I'm wrapping these inside a function in a custom module. Any pointers would be greatly appreciated.

UPDATE: works perfectly with key authentication disabled.

ngstigator’s picture

Response to #41

Line 6
$url .= "/method=user.get&id=1&hash=" . $hash;
should be:
$url .= $domain . "/method=user.get&id=1&hash=" . $hash;

Might return the HTML for "Page not found", however.

voxpelli’s picture

Status: Active » Fixed

In response to #55 - seems like a check for libxml2 should be added to the REST Server then.

In response to #56 - the Node Resource from Services 2.x is the preferred way to use nodes with the Rest Server. With it you just do a "GET /services/rest/node/123" to get the node.

In response to #57 - how a specific resource works is nothing that the REST Server deals with - that's a Services issue.

I'm closing this issue now - we don't need everyone asking their individual questions in the same issue. If you still have any outstanding questions please create a new issue for them. 63 comments makes it impossible to get a good overview so this issue will never get more solved than it is now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

anilkhadka’s picture

I enabled service-views module and now views is shown as resources but when I visit this URL

http://localhost/drupal/note/views/get?view_name='blog'

but I could not able to get Content of views.

If possible I also wanted to use views as a searching engine by using services module and rest server.Is there any solution

Thank you.

edup_pt’s picture

FileSize
42.86 KB
42.31 KB
68.58 KB
72.36 KB
70.51 KB
91.85 KB

Hi,

I've just installed drupal 7.10 and services (3.1) plugin with rest, (after installing Chaos tools). I've added the file spyc.php into the lib.

Im have setted the xmlrpc and its working, but i cant put any rest service working. It always give me 404 Page Not Found.

- Im setting the service like every post i read says but really no luck

I've added some screenshoots in order for you to see my configurations.

Any kind of help i would appreciatte.

Thanks.

edup_pt’s picture

Ok. Problem fixed. I didn't have the pretty url's turned on.

Thanks.