Reputation: 218
I`m using https://github.com/microsoftgraph/aspnet-snippets-sample sample to access my AD using Graph API, but I need to get events of specific user. There are only sample for getting my events:
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;
}
And according to guide I should request
GET /users/{id | userPrincipalName}/calendar/events
To access another user events, but how? There is no possibility to get events from Users prop:
graphClient.Users[id].Request();
Please explain me. Every info will be usefull.
Upvotes: 2
Views: 1651
Reputation: 3461
You can get to the events from the users property:
var events = await graphClient.Users[userid].Events.Request().GetAsync();
Upvotes: 3