Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to bypass Etag check in People API?

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"
  }
}
like image 855
Ranjani Avatar asked Nov 15 '22 21:11

Ranjani


1 Answers

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 *

like image 70
Zunair Avatar answered Dec 25 '22 22:12

Zunair