0

Google's documentation states that Users.update will only update fields included in the userResource object. https://developers.google.com/admin-sdk/directory/v1/reference/users/update

In my script, I am able to submit updates successfully, but when I do, fields not specified are cleared out. Here's an example:

Original user resource:

{
    orgUnitPath=/,
    ...
    "organizations": [
                    {
                      "name": "John",
                      "title": "developer",
                      "primary": true,
                      "department": "IT",
                      "location": "CA",
                      "description": "fulltime_employee",
                      "domain": "acme.com",
                      "costCenter": "123456"
                    }]
}

I want to update just one of the fields, title = 'Sr. Developer'. When I submit the partial userResource with Users.update, the rest of the fields within the array element are cleared even though they were not submitted.

Submitted userResource

{
    orgUnitPath=/,
    ...
    "organizations": [
                    {
                      "title": "sr. developer"
                    }]
}

Updated user

{
    orgUnitPath=/,
    ...
    "organizations": [
                    {
                      "name": "",
                      "title": "sr. developer",
                      "primary": true,
                      "department": "",
                      "location": "",
                      "description": "",
                      "domain": "",
                      "costCenter": ""
                    }]
}

Is there a way to correct this, or do I need to load each field within the element and submit them all with only the changed fields updated?

Ben
  • 43
  • 4
  • I think it's part of the request body to also include all of the given parameter that you want to use with the field you want to update. – Jessica Rodriguez Feb 13 '19 at 15:37
  • Not sure I follow your comment. If you are required to supply all the previously populated fields, then you are no longer doing a patch, its a full profile update. – Ben Feb 13 '19 at 17:12

0 Answers0