Closed RogerTimmerman closed 2 months ago
Thanks for raising this @RogerTimmerman
This is related to the issue at https://github.com/microsoft/kiota-dotnet/issues/310 and resolved with https://github.com/microsoft/kiota-dotnet/pull/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 Thanks for the response, I will check as soon as possible. Roger
@andrueastman Hi Andrew,
I now use a newer Microsoft.Kiota.Abstractions (>= 1.12.0) assembly and it works, Emails are serialized and deserialized properly, with and without attachments.
Thanks for the guidance With regards Roger Timmerman
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(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\nTest with Small attachment
Test with Small attachment
Configuration
OS: Windows server 2019 64 bits
Other information
No response