-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Describe the bug
I am using the C# nuget package to post a calendar event. version 5.73 and .NET 8
await graphClient.Users[senderAddress] .Calendar .Events .PostAsync(newCalendarEvent);
where newCalendarEvent is type Event
The Event class defaults List properties to null rather than empty list as they are nullable, and so in the payload request that gets generated, they are null. As far as I can tell GetFieldDeserializers() also will return null rather than falling back on an empty list.
"Attachments": null,
This results in the following error
"Exception":"Microsoft.Graph.Models.ODataErrors.ODataError: were unable to deserialize \n at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponseAsync(HttpResponseMessage response, Dictionary2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken)\n at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken)\n at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken)\n at Microsoft.Graph.Users.Item.Calendar.Events.EventsRequestBuilder.PostAsync(Event body, Action1 requestConfiguration, CancellationToken cancellationToken)\n ....
I've found that for various missing fields I either get this or a 500 "The operation failed" - instead of any sort of 400 validation messages.
So I had to guess and check a bunch of fields, and manually set them to empty list in order for my payload to go through.
Expected behavior
I would expect to receive a clear validation response detailing what fields are required or what is wrong with the payload format. If the fields are optional, they should not break when sent as null.
How to reproduce
Using a .NET 8 Web API project. Nullable context is not enabled.
Instantiate an empty event: Event newCalendarEvent = new Event();
Set the following fields with valid data:
- IsOnlineMeeting
- IsOrganizer
- OnlineMeetingProvider
- Subject
- Start
- End
- IsReminderOn
- ReminderMinutesBeforeStart
- AllowNewTimeProposals
- Attendees
Post the payload using a GraphServiceClient
await graphClient.Users[senderAddress]
.Calendar
.Events
.PostAsync(newCalendarEvent);
SDK Version
5.73
Latest version known to work for scenario above?
No response
Known Workarounds
I had to guess and check a bunch of fields, and manually set them to empty list in order for my payload to go through.
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_