I am trying to register a new user on Drupal7 via services with JSON. Actually I am posting info from JAVA (android) with JSON format to the server with services module enabled. A sample successful JSON post is:

    "name": "erfan",
    "pass": "1234",
    "mail": "[email protected]",
    "status": "1"

URL: [siteURL]/[endpoint]/user/register

I was successful creating users with basic info such as name,email,status.

I have added custom fields like field_address, field_phone, etc to the web site and want to send them via JSON to the server.

The problem is I can not figure out how to post these data to the server and couldn't find any documentation about it. My trial and error approach was not successful too, because I am not good in PHP coding. So please help me. Thanks.

  • 1
    Could you edit the question and add one of the attempts? It'll be a bit easier to advise once we've seen the code. Entity fields are structured like $account->field_name[$language][$delta][$column_name] if that helps. An example for a text field might be $account->field_foo[LANGUAGE_NONE][0]['value']
    – Clive
    Commented Jan 10, 2014 at 19:00
  • I added more details about my problem. I am not a PHP expert. :)
    – erfannf2
    Commented Jan 10, 2014 at 19:43

3 Answers 3


Hope this will help you,

In Drupal 7 you can use the below JSON format to add custom fields(field_user_image)

    "name": "test",
    "pass": "password",
    "mail": "[email protected]",
    "field_user_image": {
        "und": [{
            "fid": "2"

I have tried in my local and it is working fine.

  • Created new field UUID

    enter image description here

  • Calling the Service using Firefox poster add-on

    enter image description here

  • Code

    "name": "testuser123", 
    "pass": "testuser123", 
    "mail": "[email protected]", 
      { "und": 
          "value": "65C7DCA4-8F03-473C-9E8F-08B3F29E91AE" 

I can able to create new user with the custom field


  • This doesn't seem to work. I'm using UUID Field, and want to create a user with a UUID, which is just a text field, really. { "name": "test", "pass": "password", "mail": "[email protected]", "field_uuid": { "und": [{ "uuid_field": "65C7DCA4-8F03-473C-9E8F-08B3F29E91AE" }] }} drupal.org/sandbox/Mile23/1326218
    – paul-m
    Commented Jul 21, 2014 at 19:22
  • I have updated my answer.
    – Inizio
    Commented Jul 22, 2014 at 10:10
  • Thanks. But nope. :-) I suppose it's something to do with the way authentication is happening, or some other configuration problem.
    – paul-m
    Commented Jul 22, 2014 at 18:00
  • I discovered I can create the user and then use PUT to update the field. The JSON above is correct, but it has to be a 2-step process. drupal.org/node/790416
    – paul-m
    Commented Jul 22, 2014 at 18:15

This should be a comment, but I haven't enough reputation ...
When you create a user, you can only pass the fields that are shown in the registration form. Otherwise you'll need first to register the user and then update it with the new fields, as @paul-m said in his comment.

To show a field in the registration form go to

configuration->people->account settings-> manage fields
click the edit link of the desired field and check "Display on user registration form."

  • Hi and welcome to Drupal Answers. Your answer in fact does contribute to the original question, so I would recommend you to re-format it and improve it.
    – Wtower
    Commented Nov 12, 2014 at 16:05
  • At the time of writing this answer probably it was not possible to update custom fields in one go, but now drupal.stackexchange.com/a/156404/11058 answer works for me. Commented Dec 3, 2018 at 19:36

The field value may have to be "flattened" in order for the user registration to work. In the example below, the field is a List (text) field with radio buttons for the widget.

  • POST ?q=[my-endpoint]/user/register.json
  • Content-Type: application/json

JSON data to POST:

  "mail":"[email protected]",
  "conf_mail":"[email protected]",

This also works for radio buttons:


However, when we use a select list widget on this same field, the JSON is formed like this:


The JSON above will not work for radio buttons, you'll get a 406 - Not Acceptable An illegal choice has been detected. Please contact the site administrator. This is a lesson and reminder that the Services module can sometimes be dependant on your field's widget when it comes to the JSON it expects.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.