How do I update my users' contacts and contact photos with the Google People API?

111 views Asked by At

I'm attempting to create contacts for my Google Workspace users to be pushed to their iOS devices via MDM Account Configuration. I'd like to include a contact photo with each contact, as well.

  1. I'm not able to create contacts for a user other than myself using the People API. I've only been able to accomplish this using GAM. I can't find any documentation of how to create contacts for anyone other than the "currently authenticated user".

Since GAM can create contacts for other users the API's will, therefore, obviously allow this practice. The People API documentation states that administrators can "Read and Manage" contacts via the People API, but that "Other Contacts" are read-only. I am NOT trying to manage "Other Contacts", so in my mind it stands to reason that I should be able to do this.

  1. I'm then not able to update the contact photo of the contacts I create for other users with GAM.

Once I create a contact using GAM I copy the contact's resource ID and paste into the following Apps Script.

function myFunction() {
   var p = 'people/~resourceId~';
   var fileID = '~fileID~';
   var blob = DriveApp.getFileById(fileID).getBlob();
   var data = Utilities.base64EncodeWebSafe(blob.getBytes());
   var request = {
      photoBytes: data
   }
   People.People.updateContactPhoto(request,p);
}

This code WORKS if the contact belongs to my Super Admin account, but not if it belongs to any of my other users.

If the contact belongs to another user I get the error, "GoogleJsonResponseException: API call to people.people.updateContactPhoto failed with error: Requested entity was not found"

Is the People API set up to prevent me from accomplishing this?

0

There are 0 answers