【问题标题】:Upload events to Google API Calendar将活动上传到 Google API 日历
【发布时间】:2013-01-28 05:43:40
【问题描述】:

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

代码:

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.Recurrence.Value... 时,一切正常,事件在 Google 日历中但不重复:(

救命!

【问题讨论】:

    标签: c# .net calendar


    【解决方案1】:

    类似问题已解决:How to create "recurData" in Google Calendar?

    所以创建一个单独的循环

    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;
    

    【讨论】:

      猜你喜欢
      • 2012-04-22
      • 2023-03-09
      • 2019-10-24
      • 2017-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多