CONTEXT
Using application permission i'm creating an event and then retrieve the attendance report from it.
CODE TO ADD EVENT
public static async Task<Event> CreateEventAsync(string emailUser, Event @event, string calendarId)
{
try
{
// Add /Events
return await graphClient.Users[emailUser].Calendars[calendarId].Events
.Request()
.AddAsync(@event);
}
catch (Exception ex)
{
throw new MosException(ex.Message);
}
}
CODE TO GET ATTENDANCE REPORT
GraphHelper.Initialize();
var organizer = await GraphHelper.GetUserAsync(emailUser);
var reponseCalendar = await GraphHelper.GetCalendarAsync(emailUser);
var graphUserId = organizer.Id;
var linktoWebUrl = "/onlineMeetings?$filter=JoinWebUrl%20eq%20'https://teams.microsoft.com/l/meetup-join/19%3ameeting_YTEz.....etc...'";
var linkGraph = "https://graph.microsoft.com/v1.0/users/" + graphUserId + linktoWebUrl;
var accessToken = GraphHelper.GetToken().Result;
var httpClient = new HttpClient();
var apiCaller = new ProtectedApiCallHelper(httpClient);
var meetingObject = await apiCaller.CallWebApiAndGetASync(linkGraph, accessToken);
var meeetingIdJson = meetingObject.Last.First.First.First.Last;//<- not cool :(
var meeetingId = meeetingIdJson.ToString();
var newLink = "https://graph.microsoft.com/beta/users/" + graphUserId + "/onlineMeetings/" + meeetingId + "/attendanceReports ";
var meetingOnline = await apiCaller.CallWebApiAndGetASync(newLink, accessToken);
var attendanceReportsByUrl = meetingOnline.Last.First.First;//<- not cool :(
RESPONSE
PROBLEME
Is there a way to do it in a proper way BUT, of course, from an Event and not an OnlineMeeting?
Firstly, what you mentioned
<- not cool
can be solved when using graph client sdk like what you did inadd event
in my opinion. You can then avoid using code like.Last.First
.Then your ultimate goal is getting
attendance report
, so you have to usingOnlineMeeting
instead ofEvent
because the api is provided by Online meeting.And you may try code below, and I noticed that you used
/beta
version api, so you need to use the beta version SDK if you want to continue to use beta version: