2012-04-10 99 views
1

Iam使用C#和Google Calendar API類「CalendarService」和「Event」。 我想在沒有任何日期(全天)的情況下將活動上傳到Google日曆。 如果我不設置Event.End屬性,我會得到一個異常。使用Google Calendar API創建全天活動

如何將我的活動設置爲全天活動?

我搜索了半天,沒有任何解決方案...

回答

4

AllDay組添加新的時間爲true:

var entry = new EventEntry(title, description, ""); 
var time = new When(); 
time.StartTime = start; 
time.AllDay = true; 

entry.Times.Add(time); 
+0

您可以添加EndTime並仍將AllDay設置爲true。這樣你可以添加一個事件多天。 – 2014-04-30 05:35:01

0

Isn't標出答案的Java ???

他問了一下c#。

Event newEvent = new Event() 
     { 

      Summary = "5ummary", 
      Location = "location avenue", 
      Description = "description", 
      Start = new EventDateTime() 
      { 
       Date = "2015-08-07", 

      }, 
      End = new EventDateTime() 
      { 
       Date = "2015-08-07", 

      }, 

     }; 
+0

我發現使用這種格式我得到一個400錯誤太短,仍然在調查。 – AussieALF 2016-10-08 02:33:06