Jericho / ZoomNet

.NET client library for the Zoom.us REST API v2
MIT License
68 stars 48 forks source link

Unable to send invitations when creating a new Chat Channel due to serialization exception #368

Closed Jericho closed 2 hours ago

Jericho commented 2 hours ago

The Chat.CreateAccountChannelAsync method throws the following exception when we create a new channel and provides email addresses:

'JsonTypeInfo metadata for type 'System.Collections.Generic.IEnumerable`1[System.Text.Json.Nodes.JsonObject]' was not provided

The root of the problem is that the payload of our request contains a JSON object with the following property:

{ "members", emails?.Select(e => new JsonObject { { "email", e } }) }

Turns out, System.Text.Json does not know how to serialize an enumeration. The solution is simply to convert the enumeration into an array like so:

{ "members", emails?.Select(e => new JsonObject { { "email", e } }).ToArray() } // <-- Notice .ToArray()

This problem was discovered by @SyedShahbaz when working on very similar code in PR #367.

Jericho commented 2 hours ago

Turns out a similar problem has been resolved in September 2022 in 69f4fbae94890a5b316880c09d323804f6e98617 but Chat.CreateAccountChannelAsync was missed.