-
Notifications
You must be signed in to change notification settings - Fork 253
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
Users[userId].MailFolders[mailFolderId].Messages[messageId].Attachments.ContentBytes does not appear to be base64 encoded #2836
Comments
Thanks for raising this @catmanjan I believe the byte array should already be base64 decoded. Decoding the For reference see the implementation links below.
|
That's true. The contents do come from the API as a base64 encoded string. But the SDK changes this to a byte array. The SDK generation process does however pull the property information from the public documentation which is the real source of the confusion here. https://learn.microsoft.com/en-us/graph/api/resources/fileattachment?view=graph-rest-1.0#properties |
Describe the bug
According to the summary comment ContentBytes is "The base64-encoded contents of the file."
However the bytes do not appear to be base64 encoded, because if I try to decode them I get an error that it is not base64 encoded
Expected behavior
Probably the comment needs to be verified
How to reproduce
var attachment = await graphClient.Users[userId].MailFolders[mailFolderId].Messages[messageId].Attachments[attachmentId]
.GetAsync() as FileAttachment;
var bytes = attachment.ContentBytes;
var base64Chars = Encoding.UTF8.GetChars(attachment.ContentBytes);
var decodedBytes = Convert.FromBase64CharArray(base64Chars, 0, base64Chars.Length);
Throws an error
SDK Version
No response
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: