I have a problem when I send an insert_calendar request to the Google Calendar API V3 and I return the following response:
Sending HTTP post https://www.googleapis.com/calendar/v3/calendars? 503
I am using the Google Ruby Client API, here:
google-api-client (0.13.1) addressable (~> 2.5, >= 2.5.1) googleauth (~> 0.5) httpclient (>= 2.8.1, < 3.0) mime-types (~> 3.0) representable (~> 3.0) retriable (>= 2.0, < 4.0)
The problem I encountered is not related to the error, but the calendar has been inserted successfully.
As you can see from the answer, I am not getting anything, which says that it was successful, despite 503 , for example, the Google Calendar ID.
The influence this has on my application is that I donβt know what I successfully synchronized, and in fact, following the documents, I implement exponential delay, so I continue to create duplicate calendars in Google calendars for my users.
In the end, I have a bunch of orphan calendars showing what I should delete with string matching.
Is this expected? Is there anything I can do to mitigate this?
This happens with regularity and is not an isolated case.
The code in question:
def handle_calendar_response(response, error) self.update_column('last_synced_at', Time.now.utc) if error.present? Airbrake.notify('Sync Calendar Sync Error', { error: error, message: error.message, calendar: self }) # String match :( if error.message =~ /not.?found/i || error.message =~ /forbidden/i Airbrake.notify('Removing user deleted calendar', { calendar: self, google_calendar_id: self.google_calendar_id, error: error, message: error.message }) self.publish_to_google = false self.google_calendar_id = nil self.save! end end end ... def insert_calendar @client.insert_calendar(google_calendar_object) do |response, error| handle_calendar_response(response, error) if response.present? self.google_calendar_id = response.id self.save! end end end
These are the methods from the synchronized calendar view in our data model. You can call insert_calendar to insert it. We always take the same action in response from Google, if we insert, update or delete, we always call handle_calendar_response .