Error when including a contact to group using People API

744 views Asked by At

I need to add a single contact to all the below groups. I tried to add the contact to groups one by one, however when I tested with the first group the API gave an error

GoogleJsonResponseException: API call to people.contactGroups.members.modify failed with error: Cannot add contacts to deprecated system contact group resource name "contactGroups/chatBuddies".

I want to add the created contact to all these groups

  • contactGroups/chatBuddies
  • contactGroups/all
  • contactGroups/friends
  • contactGroups/coworkers
  • contactGroups/family
  • contactGroups/blocked

I dont see anywhere that these groups are depreciated

I have tried with

var b = {
    "phoneNumbers": [{
        "type": "mobile",
        "value": "09876543210"
    }],
    "names": [{
        "unstructuredName": "Test account"
    }],
    "urls": [],
    "addresses": [{
        "type": "work",
        "formattedValue": "0"
    }],
    "organizations": [{
        "name": "Organisation"
    }],
    "emailAddresses": [{
        "type": "home",
        "value": "[email protected]"
    }]
}

function doGet(e) {
    var resource = People.People.createContact(b);
    var id = resource.metadata.sources[0].id;
    var contactResourceName = resource["resourceName"];
    var group = People.ContactGroups.get("contactGroups/friends");
    var groupResourceName = group["resourceName"];
    var membersResource = {
        "resourceNamesToAdd": [
            contactResourceName
        ]
    }
    People.ContactGroups.Members.modify(membersResource, groupResourceName);
    return ContentService.createTextOutput(JSON.stringify(group));
}
1

There are 1 answers

0
Oleg Valter is with Ukraine On BEST ANSWER

Where was the deprecation notice?

It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of the Leopard."

In all seriousness, advanced services are thin layers wrapping the corresponding REST APIs, in this case, People API, therefore each method of the service has a corresponding method exposed by the API, specifically contactGroups.members.modify.

The description of the method reads as follows, clearly outlining that system contact groups are, in fact, deprecated:

The only system contact groups that can have members added are contactGroups/myContacts and contactGroups/starred. Other system contact groups are deprecated and can only have contacts removed.


Can I update system groups via the API directly?

It does not seem to be possible, as adding system groups to contact when updating memberships field via the people.updateContact method is explicitly forbidden (you have to examine the ContactGroupMembership resource docs to find the info):

Any contact group membership can be removed, but only user group or "myContacts" or "starred" system group memberships can be added.