Events: insert

建立事件。 立即試用查看範例

要求

HTTP 要求

POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events

參數

參數名稱 說明
路徑參數
calendarId string 日曆 ID。如要擷取日曆 ID,請呼叫 calendarList.list 方法。如果要存取目前登入使用者的主要日曆,請使用「primary」關鍵字。
自選查詢參數
conferenceDataVersion integer API 用戶端支援的會議資料版本號碼。第 0 版假設不支援會議資料,也不會忽略活動內文中的會議資料。在第 1 版中,您可以支援複製 ConferenceData,以及使用會議資料的 createRequest 欄位建立新會議。預設值為 0。可接受的值為 01 (含頭尾)。
maxAttendees integer 回應的參與者人數上限。如果參與者人數超過指定人數,系統只會傳回參與者。選填。
sendNotifications boolean 已淘汰,請改用 sendUpdates

是否要傳送新活動建立作業的通知。請注意,即使您將值設為 false,系統仍可能會傳送某些電子郵件。預設值為 false
sendUpdates string 是否傳送新活動建立的通知。請注意,系統可能仍會傳送某些電子郵件。預設為 false

可接受的值為:
  • all」:系統會將通知傳送給所有邀請對象。
  • externalOnly」:通知只會傳送給非 Google 日曆邀請對象。
  • none」:不傳送任何通知。
supportsAttachments boolean API 用戶端執行作業是否支援事件附件。選用設定。預設值為「False」。

授權

此要求至少需要以下其中一個範圍的授權:

範圍
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.events

詳情請參閱驗證和授權頁面。

要求主體

在要求內容中,提供具有以下屬性的事件資源

資源名稱 說明 附註
必要屬性
end nested object 活動 (不含) 的結束時間。如果是週期性活動,這是第一次活動的結束時間。
start nested object 事件的開始時間 (含)。如果是週期性活動,這是第一次活動的開始時間。
選用屬性
anyoneCanAddSelf boolean 是否有人可以邀請自己參加活動 (已淘汰)。選用設定。預設值為「False」。 可寫入
attachments[].fileUrl string 附件的網址連結。

如要新增 Google 雲端硬碟檔案附件,請使用與 Drive API 中 Files 資源 alternateLink 屬性相同的格式。

新增附件時必須提供。

可寫入
attendees[] list 活動的與會者。如要進一步瞭解如何與其他日曆使用者安排活動,請參閱「有與會者的活動」指南。服務帳戶必須使用全網域授權委派功能,才能填入參與者清單。 可寫入
attendees[].additionalGuests integer 額外房客人數。選用設定。預設值為 0。 可寫入
attendees[].comment string 參與者的回覆留言。選填。 可寫入
attendees[].displayName string 參與者的姓名 (如有)。選填。 可寫入
attendees[].email string 參加者的電子郵件地址 (如果有的話)。新增與會者時,必須填寫這個欄位。根據 RFC5322 規定,該電子郵件地址必須是有效的電子郵件地址。

新增與會者時必填。

可寫入
attendees[].optional boolean 是否為選填的參與者。選用設定。預設值為「False」。 可寫入
attendees[].resource boolean 與會者是否為資源。只有在首次加入活動參與者時才能設定。這樣之後的修改會遭到忽略。選用設定。預設值為「False」。 可寫入
attendees[].responseStatus string 參與者的回覆狀態。可能的值包括:
  • needsAction」:參與者尚未回覆邀請 (建議用於新活動)。
  • declined」:這名參與者已拒絕邀請。
  • tentative」:參與者已暫時接受邀請。
  • accepted」:這名參與者已接受邀請。
可寫入
colorId string 事件的顏色。這個 ID 是指顏色定義中 event 部分的項目 (請參閱「 顏色端點」)。選填。 可寫入
conferenceData nested object 會議相關資訊,例如 Google Meet 會議的詳細資料。如要建立新的會議詳細資料,請使用 createRequest 欄位。如要保留變更,請記得將所有事件修改要求的 conferenceDataVersion 要求參數設為 1 可寫入
description string 活動的說明。可以包含 HTML。選填。 可寫入
end.date date 如果是全天活動,日期,格式為「yyyy-mm-dd」。 可寫入
end.dateTime datetime 時間,採用合併日期時間值 (根據 RFC3339 格式化)。除非 timeZone 中明確指定時區,否則必須提供時區偏移。 可寫入
end.timeZone string 指定時間的時區。(格式為 IANA 時區資料庫名稱,例如「Europe/Zurich」)。如果是週期性活動,則為必填欄位,並指定重複活動的時區。如果是單一活動,則為選填欄位,用來表示活動開始/結束的自訂時區。 可寫入
eventType string 事件的特定類型。這項設定在事件建立後便無法修改。可能的值包括:
  • default」- 一般活動或未指定進一步。
  • outOfOffice」- 不在辦公室的活動。
  • focusTime」:專注時間活動。
  • workingLocation」:工作地點活動。
目前只能使用 API 建立「default」和「workingLocation」事件。我們將在後續版本中為其他活動類型提供更進一步的支援。
可寫入
extendedProperties.private object 這個日曆上活動副本的私人屬性。 可寫入
extendedProperties.shared object 在其他參與者日曆的活動副本之間共用的屬性。 可寫入
focusTimeProperties nested object 專注時間事件資料。在 eventTypefocusTime 時使用。 可寫入
gadget.display string 小工具的顯示模式。已淘汰,可能的值包括:
  • icon」:在日曆檢視畫面中,這個小工具會顯示在活動標題旁邊。
  • chip」:按下事件後會顯示這個小工具。
可寫入
gadget.height integer 小工具的高度 (以像素為單位)。高度須為大於 0 的整數。選用設定。已淘汰。 可寫入
gadget.preferences object 可寫入
gadget.title string 小工具的標題。已淘汰。 可寫入
gadget.type string 小工具的類型。已淘汰。 可寫入
gadget.width integer 小工具的寬度 (以像素為單位)。寬度須為大於 0 的整數。選用設定。已淘汰。 可寫入
guestsCanInviteOthers boolean 發起人以外的與會者是否可以邀請其他人參加活動。選用設定。預設值為 True。 可寫入
guestsCanModify boolean 發起人以外的與會者是否可以修改活動。選用設定。預設值為「False」。 可寫入
guestsCanSeeOtherGuests boolean 發起人以外的與會者是否能查看活動與會者的身分。選用設定。預設值為 True。 可寫入
id string 不透明的事件 ID。建立新的單次或週期性活動時,您可以指定活動 ID。提供的 ID 必須遵循下列規則:
  • ID 中允許的字元是 Base32 十六進位編碼使用的字元,即小寫英文字母 a-v 和數字 0-9,請參閱 RFC2938 的 3.1.2 節。
  • ID 的長度必須介於 5 至 1,024 個字元之間
  • 每個日曆的 ID 不得重複
由於系統遍布全球,我們無法保證在活動建立時會偵測到 ID 衝突。為了盡可能降低碰撞風險,建議您使用現成的 UUID 演算法,例如 RFC4122 中所述。

如果未指定 ID,伺服器會自動產生這個 ID。

請注意,icalUIDid 並非完全相同,而且只能在事件建立時提供。兩者語意的差別在於,在週期性事件中,單一事件的所有發生時都會有不同的 id,但所有活動的 icalUID 都相同。

可寫入
location string 活動的地理位置,以任意形式的文字表示。選填。 可寫入
originalStartTime.date date 如果是全天活動,日期,格式為「yyyy-mm-dd」。 可寫入
originalStartTime.dateTime datetime 時間,採用合併日期時間值 (根據 RFC3339 格式化)。除非 timeZone 中明確指定時區,否則必須提供時區偏移。 可寫入
originalStartTime.timeZone string 指定時間的時區。(格式為 IANA 時區資料庫名稱,例如「Europe/Zurich」)。如果是週期性活動,則為必填欄位,並指定重複活動的時區。如果是單一活動,則為選填欄位,用來表示活動開始/結束的自訂時區。 可寫入
outOfOfficeProperties nested object 「不在辦公室」的活動資料。在 eventTypeoutOfOffice 時使用。 可寫入
recurrence[] list 週期性事件的 RRULE、EXRULE、RDATE 和 EXDATE 行清單,如 RFC5545 中指定。請注意,這個欄位中不允許使用 DTSTART 和 DTEND 行;活動的開始和結束時間需在 startend 欄位中指定。若是單一活動或週期性活動,則會忽略這個欄位。 可寫入
reminders.overrides[] list 如果活動並未使用預設提醒,這裡會列出該活動專屬的提醒;如未設定,則會指出該活動尚未設定提醒。覆寫提醒數量上限為 5 個。 可寫入
reminders.overrides[].method string 這則提醒使用的方法。可能的值包括:
  • email」:系統會透過電子郵件傳送提醒。
  • popup」:會透過使用者介面彈出式視窗傳送提醒。

新增提醒時必須提供。

可寫入
reminders.overrides[].minutes integer 活動開始前的分鐘數,應在活動開始之前觸發。有效值介於 0 到 40320 (4 週以分鐘為單位) 之間。

新增提醒時必須提供。

可寫入
reminders.useDefault boolean 日曆的預設提醒是否適用於活動。 可寫入
sequence integer 每個 i Calendar 的序號。 可寫入
source.title string 來源的標題,例如網頁標題或電子郵件主旨。 可寫入
source.url string 指向資源的來源網址。網址配置必須是 HTTP 或 HTTPS。 可寫入
start.date date 如果是全天活動,日期,格式為「yyyy-mm-dd」。 可寫入
start.dateTime datetime 時間,採用合併日期時間值 (根據 RFC3339 格式化)。除非 timeZone 中明確指定時區,否則必須提供時區偏移。 可寫入
start.timeZone string 指定時間的時區。(格式為 IANA 時區資料庫名稱,例如「Europe/Zurich」)。如果是週期性活動,則為必填欄位,並指定重複活動的時區。如果是單一活動,則為選填欄位,用來表示活動開始/結束的自訂時區。 可寫入
status string 活動狀態。選用設定。可能的值包括:
  • confirmed」- 已確認活動。此為預設狀態。
  • tentative」:已暫時確認活動。
  • cancelled」:活動已取消 (已刪除)。list 方法只會在漸進式同步 (指定 syncTokenupdatedMin) 或 showDeleted 旗標設為 true 時傳回取消的事件。get 方法一律會傳回這些函式。

    根據事件類型,取消狀態代表兩種狀態:

    1. 因未取消週期性事件而取消的例外狀況,表示我們不應再向使用者顯示這個執行個體。用戶端應在父項週期性活動的生命週期中儲存這些事件。

      已取消的例外狀況保證將填入 idrecurringEventIdoriginalStartTime 欄位的值。其他欄位可能是空白的。

    2. 所有其他已取消的活動都代表已刪除的活動。用戶端應移除本機已同步處理的副本。這類取消的活動最終會消失,因此請勿無限期保留這些活動。

      已刪除的活動只能保證 id 欄位填入資料。

    發起人的日曆會繼續顯示已取消的活動,例如摘要、位置等,讓使用者可以還原 (取消刪除) 活動。同樣地,使用者受邀以及手動移除的活動仍會持續提供詳細資訊。不過,將 showDeleted 設為 false 的漸進式同步處理要求不會傳回這些詳細資料。

    如果活動變更主辦者 (例如透過移動作業),而原始發起人不在參與者名單中,就會在取消活動後離開,且保證只會填入 id 欄位。

可寫入
summary string 活動名稱。 可寫入
transparency string 該活動是否封鎖日曆上的時間。選用設定。可能的值包括:
  • opaque」- 預設值。該活動會在日曆上封鎖時間。這等同於在 Google 日曆 UI 中將「狀態顯示為」設為「忙碌」
  • transparent」- 活動未在日曆上封鎖時間。這等同於在 Google 日曆 UI 中將「狀態顯示方式」設為「有空」
可寫入
visibility string 活動的顯示設定。選用設定。可能的值包括:
  • default」:使用日曆上活動的預設顯示設定。這是預設值。
  • public」- 活動公開,且日曆的所有讀者都能看到活動詳細資訊。
  • private」:這是私人活動,只有活動參與者可以查看活動詳細資訊。
  • confidential」:這是私人活動。系統會基於相容性考量提供這個值。
可寫入
workingLocationProperties nested object 處理工作地點事件資料。 可寫入
workingLocationProperties.customLocation object 如果有此設定,代表使用者可在自訂位置工作。 可寫入
workingLocationProperties.customLocation.label string 選填的額外標籤。 可寫入
workingLocationProperties.homeOffice any value 如果顯示,就會指出使用者在家中工作。 可寫入
workingLocationProperties.officeLocation object 如果存在,請指明使用者在辦公室工作。 可寫入
workingLocationProperties.officeLocation.buildingId string 選用的建築物 ID。這應參照機構資源資料庫中的建築物 ID。 可寫入
workingLocationProperties.officeLocation.deskId string 選用的桌面 ID。 可寫入
workingLocationProperties.officeLocation.floorId string 選用的樓層 ID。 可寫入
workingLocationProperties.officeLocation.floorSectionId string 選用的樓層分區 ID。 可寫入
workingLocationProperties.officeLocation.label string Google 日曆網頁版和行動版用戶端顯示的辦公室名稱。建議您參考機構資源資料庫中的建築物名稱。 可寫入
workingLocationProperties.type string 工作地點類型。可能的值包括:
  • homeOffice」- 使用者在家工作。
  • officeLocation」:使用者在辦公室工作。
  • customLocation」- 使用者從自訂位置工作。
所有詳細資料皆已指定於指定名稱的子欄位,但留空可能會留空。系統會忽略任何其他欄位。

新增工作地點屬性時為必填。

可寫入

回應

如果成功,這個方法會在回應主體中傳回事件資源

範例

注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面

Java

使用 Java 用戶端程式庫

// Refer to the Java quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/java
// Change the scope to CalendarScopes.CALENDAR and delete any stored
// credentials.

Event event = new Event()
    .setSummary("Google I/O 2015")
    .setLocation("800 Howard St., San Francisco, CA 94103")
    .setDescription("A chance to hear more about Google's developer products.");

DateTime startDateTime = new DateTime("2015-05-28T09:00:00-07:00");
EventDateTime start = new EventDateTime()
    .setDateTime(startDateTime)
    .setTimeZone("America/Los_Angeles");
event.setStart(start);

DateTime endDateTime = new DateTime("2015-05-28T17:00:00-07:00");
EventDateTime end = new EventDateTime()
    .setDateTime(endDateTime)
    .setTimeZone("America/Los_Angeles");
event.setEnd(end);

String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=2"};
event.setRecurrence(Arrays.asList(recurrence));

EventAttendee[] attendees = new EventAttendee[] {
    new EventAttendee().setEmail("lpage@example.com"),
    new EventAttendee().setEmail("sbrin@example.com"),
};
event.setAttendees(Arrays.asList(attendees));

EventReminder[] reminderOverrides = new EventReminder[] {
    new EventReminder().setMethod("email").setMinutes(24 * 60),
    new EventReminder().setMethod("popup").setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
    .setUseDefault(false)
    .setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);

String calendarId = "primary";
event = service.events().insert(calendarId, event).execute();
System.out.printf("Event created: %s\n", event.getHtmlLink());

Python

使用 Python 用戶端程式庫

# Refer to the Python quickstart on how to setup the environment:
# https://developers.google.com/calendar/quickstart/python
# Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
# stored credentials.

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': 'lpage@example.com'},
    {'email': 'sbrin@example.com'},
  ],
  'reminders': {
    'useDefault': False,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10},
    ],
  },
}

event = service.events().insert(calendarId='primary', body=event).execute()
print 'Event created: %s' % (event.get('htmlLink'))

PHP

使用 PHP 用戶端程式庫

// Refer to the PHP quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/php
// Change the scope to Google_Service_Calendar::CALENDAR and delete any stored
// credentials.

$event = new Google_Service_Calendar_Event(array(
  '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' => array(
    'dateTime' => '2015-05-28T09:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'end' => array(
    'dateTime' => '2015-05-28T17:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'recurrence' => array(
    'RRULE:FREQ=DAILY;COUNT=2'
  ),
  'attendees' => array(
    array('email' => 'lpage@example.com'),
    array('email' => 'sbrin@example.com'),
  ),
  'reminders' => array(
    'useDefault' => FALSE,
    'overrides' => array(
      array('method' => 'email', 'minutes' => 24 * 60),
      array('method' => 'popup', 'minutes' => 10),
    ),
  ),
));

$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);

Ruby

使用 Ruby 用戶端程式庫

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: Google::Apis::CalendarV3::EventDateTime.new(
    date_time: '2015-05-28T09:00:00-07:00',
    time_zone: 'America/Los_Angeles'
  ),
  end: Google::Apis::CalendarV3::EventDateTime.new(
    date_time: '2015-05-28T17:00:00-07:00',
    time_zone: 'America/Los_Angeles'
  ),
  recurrence: [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  attendees: [
    Google::Apis::CalendarV3::EventAttendee.new(
      email: 'lpage@example.com'
    ),
    Google::Apis::CalendarV3::EventAttendee.new(
      email: 'sbrin@example.com'
    )
  ],
  reminders: Google::Apis::CalendarV3::Event::Reminders.new(
    use_default: false,
    overrides: [
      Google::Apis::CalendarV3::EventReminder.new(
        reminder_method: 'email',
        minutes: 24 * 60
      ),
      Google::Apis::CalendarV3::EventReminder.new(
        reminder_method: 'popup',
        minutes: 10
      )
    ]
  )
)

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

.NET

使用 .NET 用戶端程式庫

// Refer to the .NET quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/dotnet
// Change the scope to CalendarService.Scope.Calendar and delete any stored
// credentials.

Event newEvent = new 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 = new EventDateTime()
    {
        DateTime = DateTime.Parse("2015-05-28T09:00:00-07:00"),
        TimeZone = "America/Los_Angeles",
    },
    End = new EventDateTime()
    {
        DateTime = DateTime.Parse("2015-05-28T17:00:00-07:00"),
        TimeZone = "America/Los_Angeles",
    },
    Recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=2" },
    Attendees = new EventAttendee[] {
        new EventAttendee() { Email = "lpage@example.com" },
        new EventAttendee() { Email = "sbrin@example.com" },
    },
    Reminders = new Event.RemindersData()
    {
        UseDefault = false,
        Overrides = new EventReminder[] {
            new EventReminder() { Method = "email", Minutes = 24 * 60 },
            new EventReminder() { Method = "sms", Minutes = 10 },
        }
    }
};

String calendarId = "primary";
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
Event createdEvent = request.Execute();
Console.WriteLine("Event created: {0}", createdEvent.HtmlLink);

查看

使用 Go 用戶端程式庫

// Refer to the Go quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/go
// Change the scope to calendar.CalendarScope and delete any stored credentials.

event := &calendar.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: &calendar.EventDateTime{
    DateTime: "2015-05-28T09:00:00-07:00",
    TimeZone: "America/Los_Angeles",
  },
  End: &calendar.EventDateTime{
    DateTime: "2015-05-28T17:00:00-07:00",
    TimeZone: "America/Los_Angeles",
  },
  Recurrence: []string{"RRULE:FREQ=DAILY;COUNT=2"},
  Attendees: []*calendar.EventAttendee{
    &calendar.EventAttendee{Email:"lpage@example.com"},
    &calendar.EventAttendee{Email:"sbrin@example.com"},
  },
}

calendarId := "primary"
event, err = srv.Events.Insert(calendarId, event).Do()
if err != nil {
  log.Fatalf("Unable to create event. %v\n", err)
}
fmt.Printf("Event created: %s\n", event.HtmlLink)

JavaScript

使用 JavaScript 用戶端程式庫

// Refer to the JavaScript quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/js
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.

var 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': 'lpage@example.com'},
    {'email': 'sbrin@example.com'}
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10}
    ]
  }
};

var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
});

request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
});

Node.js

使用 Node.js 用戶端程式庫

// Refer to the Node.js quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/node
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.

var 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': 'lpage@example.com'},
    {'email': 'sbrin@example.com'},
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10},
    ],
  },
};

calendar.events.insert({
  auth: auth,
  calendarId: 'primary',
  resource: event,
}, function(err, event) {
  if (err) {
    console.log('There was an error contacting the Calendar service: ' + err);
    return;
  }
  console.log('Event created: %s', event.htmlLink);
});

試試看!

您可以使用下方的 APIs Explorer,針對即時資料呼叫這個方法,然後查看回應。