google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

How to creat a delete fuction for google people API

Open techmodule opened this issue 6 years ago • 2 comments

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 avatar Jul 14 '20 00:07 techmodule

@techmodule Can you elaborate on what isn't working? Do you get a response from the API?

busunkim96 avatar Jul 14 '20 19:07 busunkim96

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.

parthea avatar Dec 07 '20 11:12 parthea