Skip to content

Unable to deserialize ChangeNotificationCollection using System.Text.Json #3042

@simontfoil

Description

@simontfoil

Describe the bug

I have a subscription set on a shared mailbox and I am using the Graph to trigger an Azure Function on the arrival of a new message. This is all working really well except I can't deserialize the notification payload using System.Text.Json. Newtonsoft works fine.
At first the Value property is always null. If I set PropertyNameCaseInsensitive to true I get an error "The JSON value could not be converted to System.Nullable`1[Microsoft.Graph.Models.ChangeType]"

It seems there is no easy way to use System.Text.Json

Expected behavior

Successful deserialization of ChangeNotificationCollection using System.Text.Json

How to reproduce

The following fails using System.Text.Json

string? payloadJson = await new StreamReader( req.Body ).ReadToEndAsync();
JsonSerializerOptions serializerSetting = new JsonSerializerOptions()
{
           PropertyNameCaseInsensitive = true
};

ChangeNotificationCollection payload = JsonSerializer.Deserialize<ChangeNotificationCollection>( payloadJson, serializerSetting );

SDK Version

5.98

Latest version known to work for scenario above?

No response

Known Workarounds

Use Newtonsoft.Json

Debug output

Click to expand log

<Log output here>

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions