Search code examples
google-apigoogle-calendar-apigoogle-workspaceetag

Google Calendar API - What should be value for ETag?


As per documentation:

The ETag (or entity tag) HTTP response header is an identifier for a specific version of a resource. It lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content was not changed. Additionally, etags help to prevent simultaneous updates of a resource from overwriting each other.

I am trying to add ETag in event using Google Calendar APIs but not clear about usage,

  • What should be value?
  • Any specific format?
  • Should ETag value be same for all events or vary event by event?
  • Should ETag value be same for all events in a calendar or vary calendar by calendar?

Solution

  • The Etag returned in the response for a lot of the Google calendar objects is simply an identifer that is created by server the last time the data in the response was changed.

    So if you make a event.get call and you get an event object back containing an etag back. The next time you make that call you again get an event object back containing an etag. If the etag is the same as the etag you had before then you know the data was not changed since the last time you checked it.

    That being said you dont create an etag. Only the server does. Etag is also not writeable by you. If you check the calendar object you will notice description is writeable etag is not. So if you try to insert a new calendar and send a value for Etag your going to get an error.

    enter image description here