So I've got this Ruby on rails app going, I have it set up with a service account to do server to server requests for the google calendar API. I have got the calendar object which has methods that include insert_event.
class CalendarController < ApplicationController
require 'googleauth'
require 'google/apis/calendar_v3'
def create_event
calendar = Google::Apis::CalendarV3::CalendarService.new
scopes = ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/drive']
calendar.authorization = Google::Auth.get_application_default(scopes)
token = calendar.authorization.fetch_access_token!
event = {
'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' => {
'dateTime' => '2015-05-28T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
},
'end' => {
'dateTime' => '2015-05-28T17:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
},
'recurrence' => [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees' => [
{'email' => 'myemail1@gmail.com'},
{'email' => 'jdong8@gmail.com'},
],
'reminders' => {
'useDefault' => false,
'overrides' => [
{'method' => 'email', 'minutes' => 24 * 60},
{'method' => 'popup', 'minutes' => 10},
],
},
}
calendar.insert_event(event, 'primary')
end
end
When I try running calendar.insert_event(event, 'primary') I get this 404 error
404 (165 bytes) 338ms>
{"domain"=>"global", "reason"=>"notFound", "message"=>"Not Found"}
Caught error {"domain"=>"global", "reason"=>"notFound", "message"=>"Not Found"}
Error - #<Google::Apis::ClientError: {"domain"=>"global", "reason"=>"notFound", "message"=>"Not Found"}>
Google::Apis::ClientError: {"domain"=>"global", "reason"=>"notFound", "message"=>"Not Found"}
The main documentation for the google calendar API uses a different set up around a client object that doesn't match with the service account documentation which suggest making a calendar object. Does anyone know how to do this even if it is a very different implementation Ideally though I would like to know what the ? I want to be able to put stuff on my calendar whenever a customer makes a delivery request.