Hi @Stephen Ketley (Solihull MBC)
Try the code snippet below, it works fine for me.
using Microsoft.Graph;
using Azure.Identity;
using Microsoft.Graph.Models;
using Microsoft.Graph.Models.ODataErrors;
try {
var requestBody = new Event
{
Subject = "Let's go for lunch",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Does mid month work for you?",
},
Start = new DateTimeTimeZone
{
DateTime = "2024-03-17T12:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2024-03-17T14:00:00",
TimeZone = "Pacific Standard Time",
},
Location = new Location
{
DisplayName = "Harry's Bar",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "******@contoso.com",
Name = "Adele Vance",
},
Type = AttendeeType.Required,
},
},
TransactionId = "5E163156-7762-4BEB-A1C6-729EA81755A7",
};
var result = await graphClient.Users["{user_id}"].Calendar.Events.PostAsync(requestBody);
}
catch (ODataError odataError)
{
Console.WriteLine(odataError.Error.Code);
Console.WriteLine(odataError.Error.Message);
}
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.