Reputation: 2093
I used Google People API v1.otherContacts.copyOtherContactToMyContactsGroup
(reference) to copy a contact from "Other Contacts" to "myContacts" contact group. I now want to delete the original contact from "Other Contacts" using the same API.
REST Resource v1.otherContacts
(reference) does not list a DELETE
action.
I tried using v1.people.deleteContact
(reference) passing the resource name of my "Other Contact":
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()
But I got an error saying:
TypeError: Parameter "resourceName" value "otherContacts/c1971897568350947161" does not match the pattern "^people/[^/]+$"
Looks like v1.people.deleteContact
does not work for deleting a contact in "Other Contacts".
How can I programmatically delete a contact from "Other Contacts"?
EDIT: Based on @DaImTo's suggestion below, I tried replacing otherContacts/
in the resource name with people/
and invoking the v1.people.deleteContact
API, but I got an error saying:
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://people.googleapis.com/v1/people/c1971897568350947161:deleteContact?alt=json returned " generic::NOT_FOUND: Contact person resources are not found.". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'resourceNames[0]', 'description': 'Resource not found.'}]}]">
Upvotes: 2
Views: 733
Reputation: 71
Looks like Other Contacts are read only, according to this announcement from Google: https://developers.google.com/contacts/v3/announcement
The new People API has the same functionality as the legacy Contacts API for all features, with the following exceptions for “Other Contacts”:
Administrators have read-only permissions for “Other Contacts” through the new scope. As sending mutate/write signals back to “Other Contacts” is not supported, your users will have to add the Other Contact as a My Contact if they wish to update its data fields.
Upvotes: 0
Reputation: 117321
I advice consulting the documentation for people.deleteContact
Required. The resource name of the contact to delete.
DELETE https://people.googleapis.com/v1/{resourceName=people/*}:deleteContact
That means it should be people/c1971897568350947161
assuming that is the id of the user you want to delete c1971897568350947161
.
Upvotes: 0