2017-02-10 46 views
0

我在圖REST API下面的語句返回的所有事件從某個日曆定日期時間內:MS圖形SDK:添加參數以CalendarView

https://graph.microsoft.com/beta/me/calendars/ID/calendarView?startDateTime=2017-02-01T10:31:37Z&endDateTime=2017-02-10T10:31:37Z

此使用SDK我怎麼會做?我得到了什麼至今:

ICalendarEventsCollectionPage retrievedEvent = await graphClient.Me.Calendars[id].CalendarView...

回答

4

您可以添加爲QueryOptions請求。


    QueryOption startDateTime = new QueryOption("startDateTime", "2017-02-01T10:31:37Z"); 
    QueryOption endDateTime = new QueryOption("endDateTime", "2017-02-10T10:31:37Z"); 
    List options = new List(); 
    options.Add(startDateTime); 
    options.Add(endDateTime); 

    ICalendarCalendarViewCollectionPage retrievedEvents = await graphClient 
                   .Me 
                   .Calendars["id"] 
                   .CalendarView 
                   .Request(options) 
                   .GetAsync(); 

+0

這很好。謝謝。但是,如果您還想將事件限制爲一個或兩個擴展的屬性值呢? –

+0

您正在添加過濾條件?您可以添加像這樣的過濾器選項: ... .Request(options) .Filter(「name eq'Contoso'」)) .GetAsync(); –

+0

我最終使用'Events'而不是'CalendarView'。根據文檔,'CalendarView'不能與'Filter'機制一起使用。但我的問題現在已經排序。謝謝。 –