Cannot deserialize change notification - JsonException due to failure converting ChangeType #2801
Labels
status:waiting-for-author-feedback
Issue that we've responded but needs author feedback to close
type:bug
A broken experience
Describe the bug
This is very similar to #998
Attempting to deserialize the payload of a notification received by a webhook fails with:
The JSON value could not be converted to System.Nullable`1[Microsoft.Graph.Models.ChangeType]. Path: $.value[0].changeType | LineNumber: 5 | BytePositionInLine: 35.
The same problem occurs for Lifecycle notifications:
JSON input formatter threw an exception: The JSON value could not be converted to System.Nullable`1[Microsoft.Graph.Models.LifecycleEventType]. Path: $.value[0].lifecycleEvent | LineNumber: 0 | BytePositionInLine: 472.
Expected behavior
The notifications variable contains a valid ChangeNotificationCollection object with one ChangeNotification.
How to reproduce
The following code will reproduce:
`// This is an actual payload sent by the service that failed in my application
string payload = @"{
""value"": [
{
""subscriptionId"": ""5c748643-b830-4b11-a165-cc4b59c9820c"",
""subscriptionExpirationDateTime"": ""2021-05-15T09:06:46.5737745-07:00"",
""changeType"": ""created"",
""resource"": ""Users/1023ccca-b008-40f6-950a-aa1951a1f0d4/Messages/AAMkADY0ZjM2ZWJlLTEwOGUtNGNiOS04MTFiLWE3Y2UwNjRiZDNiMQBGAAAAAACWRvY6Vjb0SabVPshsbtVRBwAtISQkTseOQLhQ9a0koD2UAAAAAAEMAAAtISQkTseOQLhQ9a0koD2UAAB9Mb9SAAA="",
""resourceData"": {
""@odata.type"": ""#Microsoft.Graph.Message"",
""@odata.id"": ""Users/1023ccca-b008-40f6-950a-aa1951a1f0d4/Messages/AAMkADY0ZjM2ZWJlLTEwOGUtNGNiOS04MTFiLWE3Y2UwNjRiZDNiMQBGAAAAAACWRvY6Vjb0SabVPshsbtVRBwAtISQkTseOQLhQ9a0koD2UAAAAAAEMAAAtISQkTseOQLhQ9a0koD2UAAB9Mb9SAAA="",
""@odata.etag"": ""W/""CQAAABYAAAAtISQkTseOQLhQ9a0koD2UAAB9GwlV"""",
""id"": ""AAMkADY0ZjM2ZWJlLTEwOGUtNGNiOS04MTFiLWE3Y2UwNjRiZDNiMQBGAAAAAACWRvY6Vjb0SabVPshsbtVRBwAtISQkTseOQLhQ9a0koD2UAAAAAAEMAAAtISQkTseOQLhQ9a0koD2UAAB9Mb9SAAA=""
},
""clientState"": ""GraphTutorialState"",
""tenantId"": ""dfa81919-e5d3-4357-82ae-6b1e672fde09""
}
]
}";
var jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
// Deserialize the JSON payload into a list of ChangeNotification
// objects
try
{
var notifications = JsonSerializer.Deserialize(payload, jsonOptions);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}`
SDK Version
5.68.0
Latest version known to work for scenario above?
No response
Known Workarounds
Creating my own ChangeNotificationCollection class with own ChangeNotification class where ChangeType and LifecycleEvent are string is working.
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: