-
Notifications
You must be signed in to change notification settings - Fork 252
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
Serializing an email message with file attachments does not serialize everything #2638
Comments
Thanks for raising this @RogerTimmerman This is related to the issue at microsoft/kiota-dotnet#310 and resolved with microsoft/kiota-dotnet#311 Any chance you can confirm that the code below works if you include the latest version of https://www.nuget.org/packages/Microsoft.Kiota.Abstractions/ (This will be included automatically in the next SDK version) the following works out for you? var jsonString = await KiotaSerializer.SerializeAsStringAsync("application/json", result, false); |
Hi @andrueastman |
@andrueastman I now use a newer Microsoft.Kiota.Abstractions (>= 1.12.0) assembly and it works, Thanks for the guidance |
Describe the bug
Hi,
We recently upgraded our application from Microsoft Graph SDK v4 to v5 and found an annoying issue in v5 in serialization of email messages with file-attachments to Json string format after receipt of an email via the Graph API's.
The serialization is performed and stored and later deserialize the Json to a email message again and e.g. forward that email including extra information.
The actual questions are:
Replies are appreciated,
With regards
Roger Timmerman
We are using Microsoft graph SDK 5.56.0 (Microsoft.Graph.Core 3.1.15) and related dependencies.
Read email message code part:
string[] properties = new string[] { "BccRecipients","Body", "CcRecipients", "CreatedDateTime", "From", "HasAttachments", "Id", "LastModifiedDateTime",
"ReceivedDateTime", "ReplyTo", "Sender", "SentDateTime", "Subject", "ToRecipients" };
Task.Run(async () =>
{
retrievedMessage = await _graphClient.Users[accountName]
.Messages[msGraphMessageId]
.GetAsync(requestConfiguration => requestConfiguration
.QueryParameters.Select = properties);
}).Wait(RequestTimeoutMs);
Inspecting the retrievedMessage object reveals all properties (including file content) are there.
Expected behavior
The expected behavior is that alike SDK v4, Json output contains all relevant properties
How to reproduce
// or:
json = KiotaJsonSerializer.SerializeAsStringAsync<Microsoft.Graph.Models.Message>(retrievedMessage).Result;
SDK Version
SDK 5.56.0 (Microsoft.Graph.Core 3.1.15)
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```Examples of serialization (v5 using JsonSerializer, v5 KiotaJsonSerializer, v4 using JsonSerializer):
Serialization in SDK 5 using JsonSerializer (file content is missing)
",{
"Attachments": [
{
"ContentType": "text/plain",
"IsInline": false,
"LastModifiedDateTime": "2024-08-22T09:35:01+00:00",
"Name": "small-attachment.txt",
"Size": 340,
"AdditionalData": {
"@odata.mediaContentType": "text/plain"
},
"BackingStore": {
"InitializationCompleted": false,
"ReturnOnlyChangedValues": false
},
"Id": "AQMkAGMzNjQ3OWJlLWRjNWItNDA2Yy04YjgxLWFiZWJmYmFiMmQ4NQBGAAADAXcZWMvdbEaSDZn7g6eWdAcAyJ0XzcbX2UiDcSve6RCRbQAAAgEMAAAAyJ0XzcbX2UiDcSve6RCRbQADejg3jAAAAAESABAA5Ba9GDKzzEiqXUYQ4M_hGA==",
"OdataType": "#microsoft.graph.fileAttachment"
}
],
"BccRecipients": [],
"Body": {
"AdditionalData": {},
"BackingStore": {
"InitializationCompleted": true,
"ReturnOnlyChangedValues": false
},
"Content": "\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style>\r\n\r\n</style><body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word"><div class="WordSection1"><p class="MsoNormal"><span lang="EN-GB">Test with Small attachment
"ContentType": 1,
"OdataType": null
},
"BodyPreview": null,
"CcRecipients": [],
"ConversationId": null,
"ConversationIndex": null,
"Extensions": null,
"Flag": null,
"From": {
"AdditionalData": {},
"BackingStore": {
"InitializationCompleted": true,
"ReturnOnlyChangedValues": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "[email protected]",
"BackingStore": {
"InitializationCompleted": true,
"ReturnOnlyChangedValues": false
},
"Name": "My Name",
"OdataType": null
},
"OdataType": null
},
"HasAttachments": true,
"Importance": null,
"InferenceClassification": null,
"InternetMessageHeaders": null,
"InternetMessageId": null,
"IsDeliveryReceiptRequested": null,
"IsDraft": null,
"IsRead": null,
"IsReadReceiptRequested": null,
"MultiValueExtendedProperties": null,
"ParentFolderId": null,
"ReceivedDateTime": "2024-08-22T09:35:01+00:00",
"ReplyTo": [],
"Sender": {
"AdditionalData": {},
"BackingStore": {
"InitializationCompleted": true,
"ReturnOnlyChangedValues": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "[email protected]",
"BackingStore": {
"InitializationCompleted": true,
"ReturnOnlyChangedValues": false
},
"Name": "My Name",
"OdataType": null
},
"OdataType": null
},
"SentDateTime": "2024-08-22T09:34:47+00:00",
"SingleValueExtendedProperties": null,
"Subject": "Small attachment",
"ToRecipients": [
{
"AdditionalData": {},
"BackingStore": {
"InitializationCompleted": false,
"ReturnOnlyChangedValues": false
},
"EmailAddress": {
"AdditionalData": {},
"Address": "[email protected]",
"BackingStore": {
"InitializationCompleted": false,
"ReturnOnlyChangedValues": false
},
"Name": "His Name",
"OdataType": null
},
"OdataType": null
}
],
"UniqueBody": null,
"WebLink": null,
"Categories": null,
"ChangeKey": null,
"CreatedDateTime": "2024-08-22T09:35:01+00:00",
"LastModifiedDateTime": "2024-08-22T09:35:17+00:00",
"AdditionalData": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('hisaddress%40mycompany.com')/messages(bccRecipients,body,ccRecipients,createdDateTime,from,hasAttachments,id,lastModifiedDateTime,receivedDateTime,replyTo,sender,sentDateTime,subject,toRecipients)/$entity",
"@odata.etag": "W/"CQAAABYAAADInRfNxtfZSINxK97pEJFtAAN54mtE""
},
"BackingStore": {
"InitializationCompleted": true,
"ReturnOnlyChangedValues": false
},
"Id": "AQMkAGMzNjQ3OWJlLWRjNWItNDA2Yy04YjgxLWFiZWJmYmFiMmQ4NQBGAAADAXcZWMvdbEaSDZn7g6eWdAcAyJ0XzcbX2UiDcSve6RCRbQAAAgEMAAAAyJ0XzcbX2UiDcSve6RCRbQADejg3jAAAAA==",
"OdataType": "#microsoft.graph.message"
}
Serialization in SDK 5 using KiotaJsonSerializer (most properties are missing)
{
"attachments": [
{
"id": "AQMkAGMzNjQ3OWJlLWRjNWItNDA2Yy04YjgxLWFiZWJmYmFiMmQ4NQBGAAADAXcZWMvdbEaSDZn7g6eWdAcAyJ0XzcbX2UiDcSve6RCRbQAAAgEMAAAAyJ0XzcbX2UiDcSve6RCRbQADejg3jAAAAAESABAA5Ba9GDKzzEiqXUYQ4M_hGA==",
"@odata.type": "#microsoft.graph.fileAttachment",
"@odata.mediaContentType": "text/plain",
"contentType": "text/plain",
"isInline": false,
"lastModifiedDateTime": "2024-08-22T09:35:01+00:00",
"name": "small-attachment.txt",
"size": 340,
"contentBytes": "U21hbGwgYXR0YWNobWVudA==",
"contentId": "[email protected]"
}
],
"sender": {
"emailAddress": {
"address": "[email protected]",
"name": "My Name"
}
}
}
Serialization in SDK 4 using JsonSerializer (everything is present)
",{
"bccRecipients": [],
"body": {
"content": "\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style>\r\n\r\n</style><body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word"><div class="WordSection1"><p class="MsoNormal"><span lang="EN-GB">Test with Small attachment
"contentType": "Html"
},
"ccRecipients": [],
"from": {
"emailAddress": {
"address": "[email protected]",
"name": "My Name"
}
},
"hasAttachments": true,
"receivedDateTime": "2024-08-22T09:35:01+00:00",
"replyTo": [],
"sender": {
"emailAddress": {
"address": "[email protected]",
"name": "My Name"
}
},
"sentDateTime": "2024-08-22T09:34:47+00:00",
"subject": "Small attachment",
"toRecipients": [
{
"emailAddress": {
"address": "[email protected]",
"name": "His Name"
}
}
],
"attachments": [
{
"contentBytes": "U21hbGwgYXR0YWNobWVudA==",
"contentId": "[email protected]",
"contentType": "text/plain",
"isInline": false,
"lastModifiedDateTime": "2024-08-22T09:35:01+00:00",
"name": "small-attachment.txt",
"size": 340,
"id": "AQMkAGMzNjQ3OWJlLWRjNWItNDA2Yy04YjgxLWFiZWJmYmFiMmQ4NQBGAAADAXcZWMvdbEaSDZn7g6eWdAcAyJ0XzcbX2UiDcSve6RCRbQAAAgEMAAAAyJ0XzcbX2UiDcSve6RCRbQADejg3jAAAAAESABAA5Ba9GDKzzEiqXUYQ4M_hGA==",
"@odata.type": "#microsoft.graph.fileAttachment",
"@odata.mediaContentType": "text/plain"
}
],
"createdDateTime": "2024-08-22T09:35:01+00:00",
"lastModifiedDateTime": "2024-08-22T09:35:17+00:00",
"id": "AQMkAGMzNjQ3OWJlLWRjNWItNDA2Yy04YjgxLWFiZWJmYmFiMmQ4NQBGAAADAXcZWMvdbEaSDZn7g6eWdAcAyJ0XzcbX2UiDcSve6RCRbQAAAgEMAAAAyJ0XzcbX2UiDcSve6RCRbQADejg3jAAAAA==",
"@odata.type": "microsoft.graph.message",
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('hisaddress%40mycompany.com')/messages(bccRecipients,body,ccRecipients,createdDateTime,from,hasAttachments,id,lastModifiedDateTime,receivedDateTime,replyTo,sender,sentDateTime,subject,toRecipients)/$entity",
"@odata.etag": "W/"CQAAABYAAADInRfNxtfZSINxK97pEJFtAAN54mtE""
}
The text was updated successfully, but these errors were encountered: