Reputation: 11
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.
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.
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?
Upvotes: 1
Views: 138