Bitwise
Bitwise

Reputation: 8461

Getting error when trying to add event to google calendar

When a user tries to add an event to their google calendar this error occurs: We're sorry. There was a problem loading your calendar. Please try again in a few minutes. I'm not sure if it's something that I'm doing in this method?

Google URL

  def google_url
    "https://www.google.com/calendar/render?action=TEMPLATE\
    &text=#{CGI.escape @event.name}\
    &dates=#{@event.starts_at.strftime('%Y%m%dT%H%M%S')}/\
    #{@event.ends_at.strftime('%Y%m%dT%H%M%S')}\
    &ctz=#{google_time_zone}\
    &details=For+details,+link+here:+#{@event_url}\
    &location=#{CGI.escape @event.location.name}+\
    #{CGI.escape(@event.location.address)}".gsub(/\s*/, "")
  end

I've honestly never used this before, but it's breaking. Does anybody know what I could be doing wrong?

Upvotes: 0

Views: 92

Answers (1)

KENdi
KENdi

Reputation: 7741

Try to use the Events: insert of the calendar API if it is working with you. You can use the Try It part here to create a calendar event in your calendar.

You can also follow the Ruby code example here on how to create an event.

event = Google::Apis::CalendarV3::Event.new{
  summary: 'Google I/O 2015',
  location: '800 Howard St., San Francisco, CA 94103',
  description: 'A chance to hear more about Google\'s developer products.',
  start: {
    date_time: '2015-05-28T09:00:00-07:00',
    time_zone: 'America/Los_Angeles',
  },
  end: {
    date_time: '2015-05-28T17:00:00-07:00',
    time_zone: 'America/Los_Angeles',
  },
  recurrence: [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  attendees: [
    {email: '[email protected]'},
    {email: '[email protected]'},
  ],
  reminders: {
    use_default: false,
    overrides: [
      {method' => 'email', 'minutes: 24 * 60},
      {method' => 'popup', 'minutes: 10},
    ],
  },
}

result = client.insert_event('primary', event)
puts "Event created: #{result.html_link}"

Upvotes: 1

Related Questions