使用VB.Net在Google日历中插入事件

时间:2016-10-13 13:20:12

标签: vb.net google-calendar-api

我正在尝试使用以下代码添加Google日历活动:

  Sub UpdateCalendar()
    Dim CalendarEvent As New Data.Event
    Dim StartDateTime As New Data.EventDateTime
    Dim A As Date
    A = "15-OCT-2016 12:00"
    StartDateTime.DateTime = A
    Dim b As Date
    b = A.AddDays(2)
    Dim EndDateTime As New Data.EventDateTime
    EndDateTime.DateTime = b
    CalendarEvent.Start = StartDateTime
    CalendarEvent.End = EndDateTime
    CalendarEvent.Id = System.Guid.NewGuid.ToString
    CalendarEvent.Description = "Test"
    service.Events.Insert(CalendarEvent, "primary").Execute()
  End Sub

但是我在最后一行收到以下错误:

Invalid resource id value. [400]

我做错了什么?

编辑:建议"重复"没有解决问题,因为它是针对Java的,它建议切换参数,但这并没有解决问题。

1 个答案:

答案 0 :(得分:0)

显然评论以下行解决了问题:

CalendarEvent.Id = System.Guid.NewGuid.ToString