1

I am a bit new to microsoft graph api.
I am attempting to get all events for an office 365 group I successfully got the results back microsoft graph explorer https://developer.microsoft.com/en-us/graph/graph-explorer

using the query https://graph.microsoft.com/v1.0/groups/88d59881-7b15-4adc-a756-5d10681cf99d/events

however I can't quite figure out how to do the same using the c# sdk. I can get the group information but I don't know how to get the array of events.

here is how I get the group information. but I'm unsure how to add in the events I now in ef core it would be groups.include(x => x.events) but that doesn't seem to work using microsoft graph sdk.

public  static Task<Group> GetGroup()
{
    EnsureGraphForAppOnlyAuth();
    // Ensure client isn't null
    _ = _appClient ??
        throw new System.NullReferenceException("Graph has not been initialized for app-only auth");

    return _appClient.Groups["88d59881-7b15-4adc-a756-5d10681cf99d"]
        .Request()
        .Select(u => new
        {
            // Only request specific properties
            u.DisplayName,
            u.Id,
            u.Description
        })
        .GetAsync();
}
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Bryan Dellinger
  • 4,724
  • 7
  • 33
  • 79

2 Answers2

2
var groupEvents = await _appClient.Groups[""].Events.Request().GetAsync();
Optimal
  • 407
  • 3
  • 9
1

Graph API Explorer has a tab Code snippets where you can find how to rewrite the query by using SDK for selected language.

enter image description here

user2250152
  • 14,658
  • 4
  • 33
  • 57
  • thanks did not see that. of course my next problem is I want to use the application credentials (app secret) and not have the user log in and it appears events does not support that authentication but I guess that will be a separate question – Bryan Dellinger Aug 28 '22 at 13:16