Closed Jericho closed 2 hours ago
The Chat.CreateAccountChannelAsync method throws the following exception when we create a new channel and provides email addresses:
Chat.CreateAccountChannelAsync
'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.
Turns out a similar problem has been resolved in September 2022 in 69f4fbae94890a5b316880c09d323804f6e98617 but Chat.CreateAccountChannelAsync was missed.
The
Chat.CreateAccountChannelAsync
method throws the following exception when we create a new channel and provides email addresses:The root of the problem is that the payload of our request contains a JSON object with the following property:
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:
This problem was discovered by @SyedShahbaz when working on very similar code in PR #367.