halcyon10
halcyon10

Reputation: 53

Can not insert new Google Calendar Event via the ruby API, reminder error

  event = Google::Apis::CalendarV3::Event.new({
    "summary":"appointment",
    "description":"placeholder",
    "start": {
     "date_time":'2016-05-28T08:00:00',
     "time_zone":'Europe/Brussels',
    },
    "end": {
     "date_time":'2016-05-28T09:00:00',
     "time_zone":'Europe/Brussels',
    },
    'reminders': {
     'useDefault': false,
     'overrides': [
       {'minutes': 840, 'method': 'popup'}
     ]
    },  
    "color_id": "11"
  })
  result = service.insert_event('primary', event)

I am trying to insert a calendar event via the ruby API. This code gives the following error:

/usr/local/rvm/gems/ruby-2.3.1/gems/google-api-client-0.9.6/lib/google/apis/core/http_command.rb:211:in `check_status': cannotUseDefaultRemindersAndSpecifyOverride: Cannot specify both default reminders and overrides at the same time. (Google::Apis::ClientError)

Any help is greatly appreciated.

Upvotes: 3

Views: 565

Answers (1)

Andres
Andres

Reputation: 11747

It may be a little late but I was having the same problem and I found a workaround.

Create the event without the reminders. Once you have the event created with the initializer set the reminders like this:

event.reminders = Google::Apis::CalendarV3::Event::Reminders.new(
    use_default: false,
    overrides: [
      Google::Apis::CalendarV3::EventReminder.new(reminder_method:"popup", minutes: reminder_minutes),
      Google::Apis::CalendarV3::EventReminder.new(reminder_method:"email", minutes: reminder_minutes)
    ]
  )

That is working for me!

Upvotes: 4

Related Questions