google-api-python-client
google-api-python-client copied to clipboard
How to creat a delete fuction for google people API
Dear I try to make o Python Def to delele contact. But it is not work Please help
def delete_contacts_with_resourceName(creds,http,number_of_contact):
# Call the People API
service = build('people', 'v1', credentials=creds)
print('Ban dang xoa', number_of_contact, 'contacts')
results = service.people().connections().list(
resourceName='people/me',
pageSize=number_of_contact,
personFields='names,emailAddresses,phoneNumbers,emailAddresses,addresses').execute()
connections = results.get('connections', [])
for person in connections:
abcd = person.get('resourceName')
service = discovery.build('people', 'v1', http=http,discoveryServiceUrl='https://people.googleapis.com/$discovery/rest')
service.people().deleteContact(resourceName={abcd}).execute()
@techmodule Can you elaborate on what isn't working? Do you get a response from the API?
Hi @techmodule,
I'm sorry that it took a while to provide a response. I ran a modified version of your sample code and I was able to delete a contact using the following:
service = build('people', 'v1', credentials=credentials)
service.people().deleteContact(resourceName=<Enter Resource Name Here>).execute()
I'm going to close this issue as I can't produce a problem but if you're still having trouble please re-open it with additional information.