Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization Issues for Null values of Graph Event Objects #2607

Closed
visnikam opened this issue Aug 2, 2024 · 13 comments
Closed

Serialization Issues for Null values of Graph Event Objects #2607

visnikam opened this issue Aug 2, 2024 · 13 comments
Labels
Question: SDK Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question

Comments

@visnikam
Copy link

visnikam commented Aug 2, 2024

Describe the bug

We have observed a serialization issue when using from Microsoft.Graph version 5.56.0 in our .NET 6 project. In Update event, patch method it adds Null values to priorities that or not assigned. we've noticed that some fields are missing in the response from event patch call e.g. attendees. We have used System.Text.Json for sterilization and also tried JsonIgnoreCondition but it didn't work while passing event object to SDK method. Microsoft Graph API team mentioned that failure or issues due to additional properties in patch request. Please suggest.

JsonSerializerOptions options = new()
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};

URL : https://graph.microsoft.com/v1.0/users/{useremail}/events/{eventId}
Http Method : Patch
SDK Method : graphClient.Users[delegatedUserEmail].Events[eCreated.Id].PatchAsync(updateEvent);
UpdateEvent Request Object:
{
"AllowNewTimeProposals": null,
"Attachments": null,
"Attendees": [
{
"ProposedNewTime": null,
"Status": null,
"Type": 0,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "abc@test.com",
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"Name": null,
"OdataType": null
},
"OdataType": "#microsoft.graph.attendee"
},
{
"ProposedNewTime": null,
"Status": null,
"Type": 0,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "xyz@test.com",
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"Name": null,
"OdataType": null
},
"OdataType": "#microsoft.graph.attendee"
}
],
"Body": {
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": true
},
"Content": "

Test Event
",
"ContentType": 1,
"OdataType": null
},
"BodyPreview": null,
"Calendar": null,
"End": null,
"Extensions": null,
"HasAttachments": null,
"HideAttendees": null,
"ICalUId": null,
"Importance": null,
"Instances": null,
"IsAllDay": null,
"IsCancelled": null,
"IsDraft": null,
"IsOnlineMeeting": null,
"IsOrganizer": null,
"IsReminderOn": true,
"Location": null,
"Locations": null,
"MultiValueExtendedProperties": null,
"OnlineMeeting": null,
"OnlineMeetingProvider": null,
"OnlineMeetingUrl": null,
"Organizer": null,
"OriginalEndTimeZone": null,
"OriginalStart": null,
"OriginalStartTimeZone": null,
"Recurrence": null,
"ReminderMinutesBeforeStart": 1532,
"ResponseRequested": null,
"ResponseStatus": null,
"Sensitivity": null,
"SeriesMasterId": null,
"ShowAs": null,
"SingleValueExtendedProperties": null,
"Start": null,
"Subject": null,
"TransactionId": null,
"Type": null,
"WebLink": null,
"Categories": null,
"ChangeKey": null,
"CreatedDateTime": null,
"LastModifiedDateTime": null,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": true
},
"Id": null,
"OdataType": "#microsoft.graph.event"
}

Expected behavior

Update Event Request Object for Patch call expected below
{
"Attendees": [
{
"ProposedNewTime": null,
"Status": null,
"Type": 0,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "abc@test.com",
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"Name": null,
"OdataType": null
},
"OdataType": "#microsoft.graph.attendee"
},
{
"ProposedNewTime": null,
"Status": null,
"Type": 0,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "xyz@test.com",
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"Name": null,
"OdataType": null
},
"OdataType": "#microsoft.graph.attendee"
}
],
"Body": {
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": true
},
"Content": "

Test Event
",
"ContentType": 1,
"OdataType": null
}
}

How to reproduce

URL : https://graph.microsoft.com/v1.0/users/{useremail}/events/{eventId}
Http Method : Patch
SDK Method : SDK Method : graphClient.Users[delegatedUserEmail].Events[eCreated.Id].PatchAsync(updateEvent);
UpdateEvent Request Object :
{
"AllowNewTimeProposals": null,
"Attachments": null,
"Attendees": [
{
"ProposedNewTime": null,
"Status": null,
"Type": 0,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "abc@test.com",
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"Name": null,
"OdataType": null
},
"OdataType": "#microsoft.graph.attendee"
},
{
"ProposedNewTime": null,
"Status": null,
"Type": 0,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "xyz@test.com",
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": false
},
"Name": null,
"OdataType": null
},
"OdataType": "#microsoft.graph.attendee"
}
],
"Body": {
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": true
},
"Content": "

Test Event
",
"ContentType": 1,
"OdataType": null
},
"BodyPreview": null,
"Calendar": null,
"End": null,
"Extensions": null,
"HasAttachments": null,
"HideAttendees": null,
"ICalUId": null,
"Importance": null,
"Instances": null,
"IsAllDay": null,
"IsCancelled": null,
"IsDraft": null,
"IsOnlineMeeting": null,
"IsOrganizer": null,
"IsReminderOn": true,
"Location": null,
"Locations": null,
"MultiValueExtendedProperties": null,
"OnlineMeeting": null,
"OnlineMeetingProvider": null,
"OnlineMeetingUrl": null,
"Organizer": null,
"OriginalEndTimeZone": null,
"OriginalStart": null,
"OriginalStartTimeZone": null,
"Recurrence": null,
"ReminderMinutesBeforeStart": 1532,
"ResponseRequested": null,
"ResponseStatus": null,
"Sensitivity": null,
"SeriesMasterId": null,
"ShowAs": null,
"SingleValueExtendedProperties": null,
"Start": null,
"Subject": null,
"TransactionId": null,
"Type": null,
"WebLink": null,
"Categories": null,
"ChangeKey": null,
"CreatedDateTime": null,
"LastModifiedDateTime": null,
"AdditionalData": {},
"BackingStore": {
"ReturnOnlyChangedValues": false,
"InitializationCompleted": true
},
"Id": null,
"OdataType": "#microsoft.graph.event"
}

SDK Version

5.56.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@visnikam visnikam added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Aug 2, 2024
@shemogumbe shemogumbe added Needs: Attention 👋 and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Aug 6, 2024
@andrueastman
Copy link
Member

Thanks for raising this @visnikam

As the models are generated by Kiota, the you would need to use the serialization helpers to serializer the models.

Any chance you can confirm if this works for you?

https://learn.microsoft.com/en-us/openapi/kiota/serialization?tabs=csharp#serialization-helpers

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Question: SDK type:question An issue that's a question and removed Needs: Attention 👋 type:bug A broken experience labels Aug 8, 2024
@visnikam
Copy link
Author

@andrueastman Could you please help us to understand where exactly model should be serialization as we pass Event object to SDK Patch method

URL : https://graph.microsoft.com/v1.0/users/{useremail}/events/{eventId}
Http Method : Patch
Code Sample :
updateEvent = new Event
{
Attendees = attendees,
Body = new ItemBody { Content = @event.Body.Content.Replace("##teamslink##", eCreated.OnlineMeeting?.JoinUrl), ContentType = BodyType.Html },
ReminderMinutesBeforeStart = reminderMinutes,
IsReminderOn = true
};

var eGraphUpdatedResponse = await graphClient.Users[delegatedUserEmail].Events[eCreated.Id]
.PatchAsync(updateEvent, requestConfiguration => requestConfiguration.Headers.Add("client-request-id", updateGuid));

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Status: No recent activity labels Aug 12, 2024
@andrueastman
Copy link
Member

Any chance you can confirm if the json for the payload is as you expect when you you obtain the json string from the payload as
below before you make the PatchAsync call?

var jsonString = await KiotaJsonSerializer.SerializeAsStringAsync(updateEvent ); 

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 14, 2024
@visnikam
Copy link
Author

@andrueastman yes, I shared sample request. we can't serialize the event like below as string. SDK patch method required event as object and not string Sterilization happens at SDK level. Please suggest, if there is SDK configuration setting for KiotaJsonSerializer

var jsonString = await KiotaJsonSerializer.SerializeAsStringAsync(updateEvent );

Code Sample :
updateEvent = new Event
{
Attendees = attendees,
Body = new ItemBody { Content = @event.Body.Content.Replace("##teamslink##", eCreated.OnlineMeeting?.JoinUrl), ContentType = BodyType.Html },
ReminderMinutesBeforeStart = reminderMinutes,
IsReminderOn = true
};

var eGraphUpdatedResponse = await graphClient.Users[delegatedUserEmail].Events[eCreated.Id]
.PatchAsync(updateEvent, requestConfiguration => requestConfiguration.Headers.Add("client-request-id", updateGuid));

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 14, 2024
@andrueastman
Copy link
Member

Apologies for not being clearer earlier, but could you share the value of the jsonString variable? It will help understand if there is an issue with the payload being sent to the API.

var jsonString = await KiotaJsonSerializer.SerializeAsStringAsync(updateEvent );

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 16, 2024
@visnikam
Copy link
Author

@andrueastman Please find below jsonString value of Event object with KiotaJsonSerializer

{
"@odata.type": "#microsoft.graph.event",
"attendees": [
{
"emailAddress": {
"address": "abc@test.com"
},
"@odata.type": "#microsoft.graph.attendee",
"type": "required"
},
{
"emailAddress": {
"address": "xyz@test.com"
},
"@odata.type": "#microsoft.graph.attendee",
"type": "required"
}
],
"body": {
"content": "

Test Event
",
"contentType": "html"
},
"isReminderOn": true,
"reminderMinutesBeforeStart": 507
}

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 19, 2024
@andrueastman
Copy link
Member

Thanks for confirming this @visnikam

It looks like the attendees property is present here in the payload. Does this update the event successfully?

To confirm, do you mean existing attendees are removed from the list when the response comes back?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 22, 2024
@visnikam
Copy link
Author

@andrueastman Yes, attendees property is present here in the payload. We do get success as response from the SDK/Graph API but sometimes attendees are null/empty in the response and in that case attendee doesn't get the invite update. Microsoft team told us that it's due to additional properties in payload passed by SDK. Please suggest

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 22, 2024
@andrueastman
Copy link
Member

Microsoft team told us that it's due to additional properties in payload passed by SDK. Please suggest

Are you able to share a sample of the additional properties that are passed? Any chance you've taken a look at the guidance at https://learn.microsoft.com/en-us/graph/api/event-update?view=graph-rest-1.0&tabs=http#notes-for-updating-specific-properties

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 23, 2024
@John-HLC
Copy link

John-HLC commented Aug 23, 2024

I stumbled across this -- it is also happening to our project as well. Same SDK version -- passing up Attendees at time of creation of the Event -- makes the list null when it's created - no Attendees.

@visnikam
Copy link
Author

Microsoft team told us that it's due to additional properties in payload passed by SDK. Please suggest

Are you able to share a sample of the additional properties that are passed? Any chance you've taken a look at the guidance at https://learn.microsoft.com/en-us/graph/api/event-update?view=graph-rest-1.0&tabs=http#notes-for-updating-specific-properties

@andrueastman They asked us not to use SDK and call Graph API call directly with sample payload like

{
"attendees": [
{
"emailAddress": {
"address": "abc@test.com"
},
"type": "required"
},
{
"emailAddress": {
"address": "xyz@test.com"
},
"type": "required"
}
],
"body": {
"content": "

Test Event
",
"contentType": "html"
},
"isReminderOn": true,
"reminderMinutesBeforeStart": 507
}

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 27, 2024
@andrueastman
Copy link
Member

@visnikam do you get a different result? The payload looks the same to the one shared earlier...

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Aug 27, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question: SDK Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question
Projects
None yet
Development

No branches or pull requests

4 participants