Chris
Chris

Reputation: 8109

Stop watching events in Google Calendar API

Assuming I am watching to events using a channel.

What is the easiest way to stop receiving notifications?

Can the callback just return 404 http status code?

Upvotes: 2

Views: 1835

Answers (1)

FullStack
FullStack

Reputation: 6020

No, an error status code does not stop you from receiving notifications. In fact, error status codes will cause more notifications as explained in the excerpt below:

To indicate success, you can return any of the following status codes: 200, 201, 202, 204, or 102. If your service returns 500, 502, 503, or 504, the Google Calendar API will retry with exponential backoff.

According to their API reference, you need to do an HTTP POST request like that below to stop the notifications. No tokens necessary.

POST https://www.googleapis.com/calendar/v3/channels/stop
Authorization: Bearer {auth_token_for_current_user}
Content-Type: application/json
{
  "id": "4ba78bf0-6a47-11e2-bcfd-0800200c9a66",
  "resourceId": "ret08u3rv24htgh289g"
}

In a different SO question, I have asked about the purpose of the resourceId here.

Upvotes: 2

Related Questions