I get a "400 Bad Call to API" error when updating an object

A 400 Bad Call to API means, as the name states, you're trying to do something the API doesn't like. But what is it?

One of the possible problems here is related to object permissions. Every object in Gamedonia has an owner, which is stored in its _acl field. Gamedonia doesn't let anyone change the owner of an object for security reasons. You may be trying to do this without realizing it.

To solve this, make sure that you're not updating an object that comes back from a search call and is NOT property of the user currently logged in (another user created it: for instance, you created the object at the Gamedonia Dashboard). It doesn't matter if the collection of the object has the permission R/W for others activated.

The way to solve this is to set the _acl field to null in the object passed to the Update method. If you don't do this, Gamedonia will think you are trying to update the _acl field, which is not permitted. Here's a small code on how to do this:

string idMatch = "56b32213e4b0d51f3cf21f4f";

GamedoniaData.Search("matches_collection", "{_id:{$oid:'"+idMatch+"'}}", delegate (bool success, IList list){  

    if (success) {

        if ((list != null)) {

            // We take the first object coming back from the search call
            Dictionary<string,object> dd = (Dictionary<string, object>)list[0];

            dd["name"] = "updated_name";    // We modify the object
            dd["_acl"] = null;          // We remove the _acl field

            // We update and everything goes fine
            GamedoniaData.Update("matches_collection", dd, delegate(bool succ_upd, IDictionary upd_d) {

                if(succ_upd) {
                    // Update SUCCESS process

                } else {
                    // Update FAIL process

        } else {

            Debug.Log("ID not found.");

    } else {
        // Search FAIL process

Remember this isn't only reason why you can get the 400 Bad Call to API. You may be doing something else wrong. But it's worth a try, and it's the most common cause of this error.