I resolved this issue by updating the permissions in the configuration file. Previously, the permission was set to calendar.read
, but after changing it to calendar.readwrite
, I successfully created the event. I think the error message is quite unclear; theoretically, it should indicate insufficient permissions.
An input string format problem occurred while creating the Event
Yan Leo
5
Reputation points
I have an application utilizing the Microsoft.Graph DLL version 5.39.0. The functionality to list events was working smoothly. However, encountering an issue occurred when attempting to create an event, leading to failure while executing the following code:
var result=await _userClient.Me.Events.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"China Standard Time\"");
});
Error:
My code (request body):
public static async Task<Event?> CreateEventAsync()
{
var requestBody = new Event
{
Subject = "Quick discussion",
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "Book meeting",
},
Start = new DateTimeTimeZone
{
DateTime = "2024-03-22T14:00:00.0000000",
TimeZone = "China Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2024-03-22T14:30:00.0000000",
TimeZone = "China Standard Time",
},
Location = new Location
{
DisplayName = "Room Uranus",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "xxxx@user.com",
Name = "Room Uranus",
},
Type = AttendeeType.Required,
}
},
AllowNewTimeProposals = true
};
var result=await _userClient.Me.Events.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"China Standard Time\"");
});
return result;
}
1 answer
Sort by: Most helpful
-
Yan Leo 5 Reputation points
2024-03-21T09:09:23.3+00:00