I used C# Graph SDK(Microsoft.Graph 5.61.0) to test Patch an Event with Application Permission
<code>/*Calendars.ReadWrite | Application | Read and write calendars in all mailboxes | Yes*/
var client = GetAppGraphServiceClient(config);
Console.WriteLine("Init Graph Client Error...");
string userId = "user-id";
string eventId = "event-id";
var theEvent = await client.Users[userId].Events[eventId].GetAsync();
var updatedAttendees = new List<Attendee>();
theEvent.Attendees.ForEach(attendee =>
if (attendee.EmailAddress.Address != "[email protected]")
//Attendee attendee1 = new Attendee();
//EmailAddress emailAddress1 = new EmailAddress();
//emailAddress1.Address = attendee.EmailAddress.Address;
//attendee1.EmailAddress = emailAddress1;
//updatedAttendees.Add(attendee1);
updatedAttendees.Add(attendee);
var updatedEvent = new Event
Attendees = updatedAttendees
var newEvent = await client.Users[userId].Events[eventId].PatchAsync(updatedEvent);
//@event.Attendees = updatedAttendees;
//var updated = await client.Users[userId].Events[eventId].PatchAsync(@event);
<code>/*Calendars.ReadWrite | Application | Read and write calendars in all mailboxes | Yes*/
var client = GetAppGraphServiceClient(config);
if (client == null) {
Console.WriteLine("Init Graph Client Error...");
return;
}
string userId = "user-id";
string eventId = "event-id";
var theEvent = await client.Users[userId].Events[eventId].GetAsync();
var updatedAttendees = new List<Attendee>();
theEvent.Attendees.ForEach(attendee =>
{
if (attendee.EmailAddress.Address != "[email protected]")
{
//Attendee attendee1 = new Attendee();
//EmailAddress emailAddress1 = new EmailAddress();
//emailAddress1.Address = attendee.EmailAddress.Address;
//attendee1.EmailAddress = emailAddress1;
//updatedAttendees.Add(attendee1);
updatedAttendees.Add(attendee);
}
});
var updatedEvent = new Event
{
Attendees = updatedAttendees
};
var newEvent = await client.Users[userId].Events[eventId].PatchAsync(updatedEvent);
//@event.Attendees = updatedAttendees;
//var updated = await client.Users[userId].Events[eventId].PatchAsync(@event);
</code>
/*Calendars.ReadWrite | Application | Read and write calendars in all mailboxes | Yes*/
var client = GetAppGraphServiceClient(config);
if (client == null) {
Console.WriteLine("Init Graph Client Error...");
return;
}
string userId = "user-id";
string eventId = "event-id";
var theEvent = await client.Users[userId].Events[eventId].GetAsync();
var updatedAttendees = new List<Attendee>();
theEvent.Attendees.ForEach(attendee =>
{
if (attendee.EmailAddress.Address != "[email protected]")
{
//Attendee attendee1 = new Attendee();
//EmailAddress emailAddress1 = new EmailAddress();
//emailAddress1.Address = attendee.EmailAddress.Address;
//attendee1.EmailAddress = emailAddress1;
//updatedAttendees.Add(attendee1);
updatedAttendees.Add(attendee);
}
});
var updatedEvent = new Event
{
Attendees = updatedAttendees
};
var newEvent = await client.Users[userId].Events[eventId].PatchAsync(updatedEvent);
//@event.Attendees = updatedAttendees;
//var updated = await client.Users[userId].Events[eventId].PatchAsync(@event);
but the Attendees of newEvent
have no any change compared with theEvent
whether it is a one-time removal or one-by-one removal.
I try to change Subject and it effects
<code>var updatedEvent2 = new Event
Subject = "Updated Subject",
var newEvent2 = await client.Users[userId].Events[eventId].PatchAsync(updatedEvent2);
<code>var updatedEvent2 = new Event
{
Subject = "Updated Subject",
};
var newEvent2 = await client.Users[userId].Events[eventId].PatchAsync(updatedEvent2);
//it had is changed
</code>
var updatedEvent2 = new Event
{
Subject = "Updated Subject",
};
var newEvent2 = await client.Users[userId].Events[eventId].PatchAsync(updatedEvent2);
//it had is changed
I also tested patching OnlineMeeting
with an application permission and application access policy. I added two attendees as participants, then tried to remove the two attendees one at a time. However, the attendees list didn’t change. If I just try to remove first attendee, it succeeded, afterwards there was just one attendee in the meeting. If I then tried to remove last attendee, the attendees list didn’t change at all.
<code>var theMeeting = await client.Users[userId].OnlineMeetings[onlineMeetingId].GetAsync();
var updatedMeeting = new OnlineMeeting
Participants = new MeetingParticipants
Attendees = new List<MeetingParticipantInfo>(),
var newMeeting = await client.Users[userId].OnlineMeetings[onlineMeetingId].PatchAsync(updatedMeeting);
<code>var theMeeting = await client.Users[userId].OnlineMeetings[onlineMeetingId].GetAsync();
var updatedMeeting = new OnlineMeeting
{
Participants = new MeetingParticipants
{
Attendees = new List<MeetingParticipantInfo>(),
}
};
var newMeeting = await client.Users[userId].OnlineMeetings[onlineMeetingId].PatchAsync(updatedMeeting);
</code>
var theMeeting = await client.Users[userId].OnlineMeetings[onlineMeetingId].GetAsync();
var updatedMeeting = new OnlineMeeting
{
Participants = new MeetingParticipants
{
Attendees = new List<MeetingParticipantInfo>(),
}
};
var newMeeting = await client.Users[userId].OnlineMeetings[onlineMeetingId].PatchAsync(updatedMeeting);
How can I use PATCH Attendees
to correctly remove attendees?