将事件上载到Google API日历

本文关键字:API 日历 Google 事件 上载 | 更新日期: 2023-09-27 17:58:55

我使用Google Calendar API编写应用程序。一切都还好,但当我尝试将重复的事件上传到谷歌时,我出现了错误。我不知道,什么是坏的。

代码:

EventEntry newEvent = new EventEntry();
newEvent.Title.Text = "Event title";
When time = new When(new DateTime(2013, 02, 12, 15, 0, 0), new DateTime(2013, 02, 12, 17, 0, 0));
newEvent.Times.Add(time);
Where place = new Where();
place.ValueString = "World";
newEvent.Recurrence = new Recurrence();
newEvent.Recurrence.Value = "DTSTART;VALUE=DATE:20130212T15000'r'n" +
                            "DTEND;VALUE=DATE:20130212T17000'r'n" +
                            "RRULE:FREQ=DAILY;BYDAY=Tu;'r'n";
service.Insert(query.Uri, newEvent);

在这种情况下,活动应该在周二每周重复一次。当我运行这个时,我会出现错误:"请求执行失败"-但当我评论newEvent.Repurrence.Value…时,一切都好,事件在谷歌日历中,但没有重复:(

救命!

将事件上载到Google API日历

解决了类似的问题:如何创建"recurData";在谷歌日历中?

所以创建一个单独的重复

EventEntry myEntry = new EventEntry();
myEntry.Title.Text = "Hello recurring Event!";
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = "here and there";
entry.Locations.Add(eventLocation);
// Any other event properties
// Recurring event:
String recurData =
  "DTSTART;VALUE=DATE:20070501'r'n" +
  "DTEND;VALUE=DATE:20070502'r'n" +
  "RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904'r'n";
Recurrence recurrence = new Recurrence();
recurrence.Value = recurData;
myEntry.Recurrence = recurrence;