Skip to content

Create Event: sending null for optional params returns nonspecific error #2860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ardian-CCM opened this issue Mar 14, 2025 · 0 comments
Open
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@ardian-CCM
Copy link

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_
@ardian-CCM ardian-CCM added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

1 participant