0
votes

I have the resourceName and etag of the person I wish to update, but I can't understand the documentation to actually execute the update.

I've looked at the API Documentation, and I feel like I'm structuring everything correctly. However, I keep getting Error 400 responses of two types:

1)

https://people.googleapis.com/v1/people/c1596007341306697743:updateContact?updatePersonFields=%7B%27emailAddresses%27%3A+%5B%7B%27value%27%3A+%27hello%40gmail.com%27%7D%5D%7D&alt=json returned "Invalid value at 'update_person_fields' (type.googleapis.com/google.protobuf.FieldMask), Field 'update_person_fields', Invalid FieldMask '{'emailAddresses': [{'value': '[email protected]'}]}'. Map keys should be represented as ["some_key"].">

2)

https://people.googleapis.com/v1/people/c1596007341306697743:updateContact?updatePersonFields=%7B%27emailAddresses%27%3A+%7B%27value%27%3A+%27hello%40gmail.com%27%7D%7D&alt=json returned "Invalid updatePersonFields mask path: "{'email_addresses': {'value': '[email protected]'}}". Valid paths are documented at https://developers.google.com/people/api/rest/v1/people/updateContact.">

The first happens when the list brackets ([ ]) are left in the updatePersonFields parameter, the second when they are taken away.

I'm doing my best to implement this entirely in Python, and succeeded with both looking at and creating contacts. It seems that the update call is somehow different than the others. Any and all input is welcomed and appreciated.

    profileCode = "people/blahblahblah" 
    accessToken = "%Eblahblahblah=" 

    update = API.people().updateContact(
        resourceName=profileCode,
        body={"resourceName":profileCode, "etag":accessToken},
        updatePersonFields={"emailAddresses":[{"value":"[email protected]"}]}
        ).execute()
1
Can I ask you about your question? What property do you want to update?Tanaike
@Tanaike, it was a problem with the updatePersonFields parameter as Amos Yuen pointed out.AndrewG
Thank you for your additional information.Tanaike

1 Answers

1
votes

Please look at the example in the documentation https://developers.google.com/people/v1/write-people#update-an-existing-contact.

updatePersonFields is just a comma separated list of the fields that should be updated e.g. emailAddresses,names. You're trying to specify the contact to update in the updatePersonFields param, that should be specified in the HTTP post body, not the updatePersonFields param.