tom
tom

Reputation: 1077

Update contact in Google People API

I'm having trouble updating the notes of contacts through Googles People API. I used some code from a previous stackoverflow answer, but it doesn't seem to work anymore. Below is the function I'm using. I'm attempting to change the notes of a particular contact to "changed bio xyz".

What am I doing wrong? The api does read a listing of the contacts, but I haven't been able to successfully write yet.

Thanks and please let me know if I can make this question more clear

results = service.people().connections().list(
    resourceName='people/me',
    pageSize=1500,
    personFields='names,emailAddresses,phoneNumbers,biographies').execute()
connections = results.get('connections', [])


aContact = service.people().get(
resourceName = 'people/c1589313158061148817',
personFields = 'biographies' ).execute()
notesNames = aContact['biographies'][0]        
notesNames['value'] = 'changed bio xyz'

result = service.people().updateContact(
resourceName = 'people/c1589313158061148817',
body = aContact, 
updatePersonFields = 'biographies'
).execute()

Upvotes: 0

Views: 1169

Answers (1)

tom
tom

Reputation: 1077

I figured it out. The update goes in the body section, and it needs to follow a dictionary format

  aContact = service.people().get(
resourceName = 'people/c36943406266964946',
personFields = 'names,nicknames'
).execute()
print ('this is acontact', aContact)
NickNames = aContact['nicknames'][0]        
NickNames['value'] = 'newNickName'

aContact['nicknames'] = NickNames
result = service.people().updateContact(
resourceName = 'people/c36943406266964946',
body = aContact, 
updatePersonFields = 'nicknames'
).execute()

Upvotes: 0

Related Questions