Any way to bypass Etag check in People API?
Asked Answered
Y

1

6

Google Contacts allows us to bypass Etag verification by passing * instead of the contact's current Etag for Edit/Delete requests.

Google Contacts API documentation

Note: The special Etag value * can be used to bypass this verification and process the update regardless of updates from other clients.

Is there any similar way to bypass the Etag verification for edit/delete in People API?

Facing the following error if the etag value is not sent in Person object during update. The value " * " is also not working in People API.

Request:

{
  "emailAddresses": [
    {
      "displayName": "[email protected]",
      "value": "[email protected]",
      "type": "home"
    }
  ]
}

Response:

{
  "error": {
    "code": 400,
    "message": "Request must set person.etag or person.metadata.sources.etag for the source that is being updated.",
    "status": "INVALID_ARGUMENT"
  }
}
Yusem answered 3/5, 2021 at 14:34 Comment(0)
R
1

You have to send the resource name in both the delete and the update requests.

Delete request only requires resource name.

Update request requires the resource name and the person. IMO the best way to update is to fetch the Person first then update the data then push it back.

updateMask is also required if you are not using one of their APIs https://developers.google.com/people/api/rest/v1/people/updateContact?hl=en

See https://developers.google.com/people/api/rest/v1/people/updateContact?hl=en

The server returns a 400 error with reason "failedPrecondition" if person.metadata.sources.etag is different than the contact's etag, which indicates the contact has changed since its data was read. Clients should get the latest person and merge their updates into the latest person.

In short, you maybe out of luck using just the *

Renoir answered 7/6, 2021 at 20:34 Comment(1)
Giving "names,addressess" works in updateMask. But if I need to change just givenName, and I give updateMask as "names.givenName" it throws the following error: { "error": { "code": 400, "message": "Invalid updatePersonFields mask path: \"names.given_name\". Valid paths are documented at https://developers.google.com/people/api/rest/v1/people/updateContact.", "status": "INVALID_ARGUMENT" } } Any idea how to give this mask?Yusem

© 2022 - 2024 — McMap. All rights reserved.