1

我使用https://github.com/microsoftgraph/aspnet-snippets-sample示例使用Graph API訪問我的AD,但我需要獲取特定用戶的事件。有隻爲讓我的事件示例:使用MS Graph API獲取另一個用戶事件

 public async Task<List<ResultsItem>> GetMyEvents(GraphServiceClient graphClient) 
    { 
     List<ResultsItem> items = new List<ResultsItem>(); 

     // Get events. 
     IUserEventsCollectionPage events = await graphClient.Me.Events.Request().GetAsync(); 

     if (events?.Count > 0) 
     { 
      foreach (Event current in events) 
      { 
       items.Add(new ResultsItem 
       { 
        Display = current.Subject, 
        Id = current.Id 
       }); 
      } 
     } 
     return items; 
    } 

,並根據指導我應要求

GET /用戶/ {ID | userPrincipalName}/calendar/events

要訪問另一個用戶事件,但如何?沒有可能從用戶prop獲得事件:

graphClient.Users [id] .Request();

請解釋一下。每個信息將是有用的。

回答

1

你可以從用戶屬性的事件:

var events = await graphClient.Users[userid].Events.Request().GetAsync(); 
相關問題