I have been trying to use the Services Browser at http://www.example.com/admin/build/services/browse/user.save to figure out how to provision a user. The idea is to login to an account that is allowed to create users from a device like an iPhone or Android. Get the user information and away we go.

But I have been having trouble formatting the request.

Sending the parameter as serialized PHP :

   stdClass Object ([name] =>'jazzMaster1', [pass] => 'test', [mail] => 'jazzMaster1@example.com' });

or:

   stdClass Object ([username] =>'jazzMaster1', [password] => 'test', [e-mail] => 'jazzMaster1@example.com' });

I get :
* Username field is required.
* Password field is required.
* You must enter an e-mail address.

The output of the code suggested on http://drupal.org/node/467786

$obj = (object)array(
  'name' =>'jazzMaster1','pass' => 'test','mail' => 'jazzMaster1@example.com' 
);
print serialize($obj)."\n";

This crashes the server:

O:8:"stdClass":3:{s:4:"name";s:11:"jazzMaster1";s:4:"pass";s:4:"test";s:4:"mail";s:23:"jazzMaster1@example.com";}

However adding "(" ... ");" is OK:

(O:8:"stdClass":3:{s:4:"name";s:11:"jazzMaster1";s:4:"pass";s:4:"test";s:4:"mail";s:23:"jazzMaster1@example.com";});

But, I get :
* Username field is required.
* Password field is required.
* You must enter an e-mail address.

Does any wizard know how to provision an account with user.save in the services module?

Comments

sasconsul’s picture

Component: Documentation » Code
marcingy’s picture

Priority: Critical » Normal

Setting priority correctly.

gdd’s picture

Title: Problem creating a user with user.save via the Services Browser » User save service indicates object parameter, code expects array.
Category: support » bug

I helped sasconsul with this on IRC. One problem here is that the documentation of the service states that it expects an object, when in fact it expects an array. We should change that in the next release of 2.x (if there is one.) It should accept an object, just as user_save() does.

A properly serialized array like

a:3:{s:4:"name";s:3:"foo";s:4:"pass";s:3:"bar";s:4:"mail";s:11:"foo@bar.com";}

worked fine for him.

sasconsul’s picture

Priority: Normal » Critical

Ok Folks, got it with the help of heyrocker on irc.

This serialized PHP works in the browser:

a:3:{s:4:"name";s:2:"j1";s:4:"pass";s:4:"test";s:4:"mail";s:10:"j1@foo.com";}

The code you test in the Services browser must fit into the text field of the Services Browser!

marcingy’s picture

Title: User save service indicates object parameter, code expects array. » Problem creating a user with user.save via the Services Browser
Category: bug » support

This is not critical.....

marcingy’s picture

Priority: Critical » Normal
Status: Active » Closed (fixed)