Cannot update checkbox with services I have been trying several configurations for trying to update a user account checkbox to uncheck it, with no success. I have been able to check it without issue.

updateCharType = function (token) {

    var obj = {
        "uid": "1",
        "name": "admin",
        "field_character_type": {"und": [{"value": 0}]}
    };
    return $.ajax({
        url: 'www.example.com/endpoint/1.json',
        crossDomain: true,
        type: 'PUT',
        data: obj,
        dataType: 'json',
        headers: {
            'X-CSRF-Token': token
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log('user edit - failed to edit ' + textStatus);
            console.log(errorThrown);
        },
        success: function (data) {
            alert(success!);
        }
    });
}


Now, it always gets to the success portion of the code, and it seems like it is working correctly.

However the checkbox never gets unchecked. I've read a bunch of documentation, and tried a million different iterations of how the JSON should be formed - putting null, removing the [], removing the und - for some reason I am having absolutely zero luck updating this checkbox!

How do I update a checkbox on a user account with services?

EDIT:

I WAS able to get it working with a list of values for a different field:

 var fontSize = jQuery('#font-size').val();

    var obj = {
        "uid": "1",
        "name": "admin",
        "field_font_size": {"und": fontSize}
    };
    return $.ajax({
        url: 'http://example.com' + "/users/user/1.json",
        crossDomain: true,
        type: 'PUT',
        data: obj,
        dataType: 'application/json',
        headers: {
            'X-CSRF-Token': token
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log('user edit - failed to edit ' + textStatus);
            console.log(errorThrown);
        },
        success: function (data) {
            alert("Success for user save!:) ");
        }
    });
};


Differences:

How to be a list of values, and I needed to set it to application/json

Boolean field still not working under any variations.

Also, whenever I try to uncheck the checkbox I get the following error:

Notice: Array to string conversion in DatabaseStatementBase-&gt;execute() (line 2227 of /Users/username/Desktop/Projects/example.com/includes/database/database.inc).
To un-check a check box with Services in Drupal 7 (aka setting false on a boolean field), try this:

"field_character_type": {"und": null}


I've just verified this works on my localhost (for both users and nodes), here's the payload for the PUT:

{
  uid: 1,
  name: "admin",
  field_character_type: { und: null }
}


And here's the path:

api/user/1.json

Make sure you include the [my-endpoint-path]/user/[uid].json for the call.

You only need to cast the data payload into a string if you're using vanilla .js and an xhr object, otherwise jQuery's ajax does it automatically for you.