2013-02-12 132 views
0

我使用Google Calendar API编写我的应用程序。一切都好,但是当我尝试将重复事件上传到Google时,我有错误。我不知道,什么是坏的。将活动上传到Google 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.Recurrence.Value ...,一切正常,事件是在谷歌日历,但不重复:(

帮助!

回答

0

类似的问题就迎刃而解了: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;