microsoft-graph-docs
microsoft-graph-docs copied to clipboard
C# Example for adding file attachment does not work and creates confusion for end-user.
Many of our users have raised concerns for our c# example w.r.t adding file attachment <3 MB.
Example as per documentation -
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Attachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "menu.txt",
AdditionalData = new Dictionary<string, object>
{
{
"contentBytes" , "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="
},
},
};
var result = await graphClient.Me.Events["{event-id}"].Attachments.PostAsync(requestBody);
Main concerns -
-
'contentBytes' is not very clear. Is this a byte array? Our documentation needs to very clearly call what should a user be passing to contentBytes.
-
How is the encoded string passed here(in contentBytes) obtained? How can we do it programmatically from a file instead of directly pasting the string here?
We need to fix our documentation to clearly call out these minute details for our customers to use this seamlessly.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 4dd65821-a482-8b49-7da5-4afdcbe6d9f0
- Version Independent ID: d964d80e-c019-aed5-a26e-489a57f0653b
- Content: Add attachment - Microsoft Graph v1.0
- Content Source: api-reference/v1.0/api/message-post-attachments.md
- Product: outlook
- Technology: microsoft-graph
- GitHub Login: @abheek-das
- Microsoft Alias: MSGraphDocsVteam