I have implemented a version of the php node.save example at http://drupal.org/node/585014 (I just needed to remove "new xmlrpcval($sessid)" from user.login as otherwise the login failed and the lines for extra content fields). Unfortunately though I get access denied. I've enabled all of the content creation and access permissions, along with service ones, and tested the role with an admin and non-admin user. I've tried both the dev and beta versions of services with drupal 6.15. I'm using xmlrpclib 3.0.0.beta.

An error occurred on node.save: Access denied

Any help would be greatly appreciated.

Comments

P.Smith’s picture

I was able to create a node using node.save in the browser (through drupal's interface).

I used the following serialized php (same fields as what the xmlrpc client is trying to send):

a:9:{s:4:"type";s:5:"story";s:6:"status";i:1;s:5:"title";s:4:"test";s:4:"body";s:4:"this";s:6:"format";i:1;s:3:"nid";
i:0;s:4:"name";s:6:"Editor";s:3:"uid";s:1:"1";s:7:"created";i:1265672918;}

But there is a message (also happens when using JSON too):

warning: Attempt to assign property of non-object in /path/to/sites/all/modules/services/services/node_service
node_service.inc on line 148.

I'm not sure if this is related or helps in anyway?

P.Smith’s picture

The access denied occurs when the following is placed into the service browser (it's the contents of $access_arguments):

a:2:{i:0;s:32:"6f20cebece2192b9ce6c8f036a10c12a";i:1;a:9:{s:3:"uid";s:1:"1";s:4:"name";s:6:"Editor";s:3:"nid";i:0;s:4:"type";s:5:"story";s:6:"format";i:1;s:5:"title";
s:4:"test";s:4:"body";s:4:"this";s:6:"status";i:1;s:7:"created";i:1265740885;}}

The code from services.module:

Lif (call_user_func_array($method['access callback'], $access_arguments) != TRUE) {
    return services_error(t('Access denied'), 401);
  }

If I reduce the contents of $access_arguments to:

a:9:{s:3:"uid";s:1:"1";s:4:"name";s:6:"Editor";s:3:"nid";i:0;s:4:"type";s:5:"story";s:6:"format";i:1;s:5:"title";s:4:"test";
s:4:"body";s:4:"this";s:6:"status";i:1;s:7:"created";i:1265740885;}

then it works. What was removed from the beginning:
a:2:{i:0;s:32:"6f20cebece2192b9ce6c8f036a10c12a";i:1;

removed from the end:
}

P.Smith’s picture

The problem on line3 148 does indeed not appear to be related. See: http://drupal.org/node/710590

I made the changes but still getting access denied. The module doesn't like the contents of $sessid?

waldmanm’s picture

Not sure if this will help, but if you're using an API key, make sure you enable node.save in that key configuration. That bit me once.

Maitreya’s picture

Also check whether the client you run on has the same time/date as the service server. I had a different timezone and thus my sessions always expired.

P.Smith’s picture

Status: Active » Closed (fixed)

Hi,

I don't use a key. I'm in a different time zone but I can't really change that on the server (it's shared hosting).

This can be closed. No idea why the beta version won't work but the last stable one does using the very same client code.