msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

[Client bug]: EducationAssignment doesn't serialize assignDateTime

Open olivermue opened this issue 1 year ago • 0 comments

Describe the bug When trying to patch the EducationAssignment.AssignDateTime via the graph service client, the value won't be set.

To Reproduce

        [Fact]
        public void EducationAssignmentSerializesAssignDateTime()
        {
            var tokenCredentials = Azure.Core.DelegatedTokenCredential.Create(null);
            var serviceClient = new GraphServiceClient(tokenCredentials);

            var source = new EducationAssignment
            {
                AssignDateTime = new DateTime(2023, 4, 13, 13, 45, 00),
            };

            var requestInfo = serviceClient
                .Education
                .Classes["classId"]
                .Assignments["assignmentId"]
                .ToPatchRequestInformation(source);

            var memory = new MemoryStream();
            requestInfo.Content.CopyTo(memory);
            var bytes = memory.ToArray();
            var json = Encoding.UTF8.GetString(bytes);

            // Currently json is only "{}"
            Assert.Contains("assignDateTime", json);
        }

Expected behavior This property (and also some others) should be writeable via the SDK. According to the documenation this value is writeable (at least under specific conditions):

Date the assignment should be published to students. Cannot be edited after the assignment has been published.

But the current serialize code shows, that not all properties are written, that are read.

Workaround Fortunately the bag AdditionalData can be misused to get the value back to graph, but this should be fixed ASAP:

source.AdditionalData["assignDateTime"] = source.AssignDateTime;

Client version 5.5.0

Additional context Currently I just stumbled across this specific property, that is accidentially marked as read-only (or what is the reason, that this property can be deserialized, but not serialized?). And potentially someone from the education team has to review all meta information to ensure, that we won't find the next missing property after this one has been fixed and released.

olivermue avatar Apr 13 '23 10:04 olivermue