Drupal Services User.register resource JSON format oddity

This is mostly a note to myself. When calling the user.register method for the Services module, the JSON data format is a little wonky:

{ "mail":"[email protected]", "postal_code":"21401", "account":{ "name":"username", "pass":"password", "mail":"[email protected]" }, "field_name":{ "und":[ { "family":"Grasmick", "given":"Matthew" } ] } }

Notice that 'mail' must be included twice. Depending on which one is missing, you may receive one of these two errors:

  • 406 Not Acceptable: E-mail field is required.
  • 401 Unauthorized: Missing required argument account

As for additional fields, such as field_name, must be defined as top-level properties in the JSON object and NOT nested in the 'account' sub-object. A little odd.

Still getting "401 Unauthorized: Missing required argument account" ? You probably messed up the JSON syntax. Check it with a JSON validator.

field_name_first[und][0][value] i have first name value how to pass this key in json i got following error...

<?xml version="1.0" encoding="utf-8"?>
<field_name_first__und__0__value>First Name field is required.</field_name_first__und__0__value>
<field_name_last__und__0__value>Last Name field is required.</field_name_last__und__0__value>

Thanks.. for article ...

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.