【发布时间】:2021-06-05 07:09:14
【问题描述】:
我使用 Google People API v1.otherContacts.copyOtherContactToMyContactsGroup (reference) 将联系人从“其他联系人”复制到“myContacts”联系人组。我现在想使用相同的 API 从“其他联系人”中删除原始联系人。
REST 资源 v1.otherContacts (reference) 未列出 DELETE 操作。
我尝试使用v1.people.deleteContact (reference) 传递我的“其他联系人”的资源名称:
import pickle
from googleapiclient.discovery import build
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
people_api = build('people', 'v1', credentials=creds)
people_service = people_api.people()
response = people_service.deleteContact(resourceName='otherContacts/c1971897568350947161').execute()
但我收到一条错误消息:
TypeError:参数“resourceName”值“otherContacts/c1971897568350947161”与模式“^people/[^/]+$”不匹配
看起来v1.people.deleteContact 不适用于删除“其他联系人”中的联系人。
如何以编程方式从“其他联系人”中删除联系人?
编辑:基于@DaImTo 的suggestion below,我尝试用people/ 替换资源名称中的otherContacts/ 并调用v1.people.deleteContact API,但我收到一条错误消息:
googleapiclient.errors.HttpError:
https://people.googleapis.com/v1/people/c1971897568350947161:deleteContact?alt=json 返回“ generic::NOT_FOUND: Contact person resources are not found.”。详细信息:“[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'resourceNames[0]', 'description': '找不到资源。 '}]}]">
【问题讨论】:
标签: google-api google-api-client google-contacts-api google-api-python-client google-people-api