I had a strange encounter when I was trying to update user data with Google App Script via the Admin SDK Directory Service I wanted to add some values for a customschema like this:
var myCustomschema = {};
myCustomschema.someField = "foo";
myCustomschema.anotherField = "bar";
var resource = {};
resource.customSchemas = myCustomschema;
var resp = AdminDirectory.Users.patch(resource, user@mydomain.de);
I did not get any error back however the data was never changed in the admin directory. I also tried to JSON.stringify(resource)
.
Then I tried something like this:
var test = {
"customSchemas": {
"myCustomschema": {
"someField": "foo",
"anotherField": "bar"
}
}
};
And this worked!
So I was wondering why? Is there even a difference between the two approached in the Javascript world? Apparently there is a difference in the Google App Script world.