使用People API将联系人包含到群组中时出错 [英] Error when including a contact to group using People API

查看:134
本文介绍了使用People API将联系人包含到群组中时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为以下所有群组添加一个联系人.我试图将联系人逐个添加到组中,但是当我与第一个组进行测试时,API出现了错误

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:对people.contactGroups.members.modify的API调用失败,并显示以下错误:无法将联系人添加到已过时的系统联系人组资源名称"contactGroups/chatBuddies".

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/全部
  • contactGroups/朋友
  • contactGroups/同事
  • contactGroups/家庭
  • contactGroups/已阻止

我看不到这些折旧的任何地方

I dont see anywhere that these groups are depreciated

我尝试过

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

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));
}

推荐答案

弃用通知在哪里?

它显示在一个锁着的文件柜的底部,该文件柜被塞在一个废弃的洗手间里,门上有一个标语当心豹子".

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."

实际上,高级服务是包裹相应REST API的薄层,在这种情况下, People API ,因此该服务的每种方法都有相应的API公开的方法,特别是

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:

唯一可以添加成员的系统联系人组是contactGroups/myContacts和contactGroups/stard.不建议使用其他系统联系人组,并且只能删除联系人.

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.


我可以直接通过API更新系统组吗?

似乎不可能,因为通过

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):

可以删除任何联系人组成员身份,但只能删除用户组或"myContacts"或加星标"可以添加系统组成员身份.

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

这篇关于使用People API将联系人包含到群组中时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆