microsoft-graph-docs icon indicating copy to clipboard operation
microsoft-graph-docs copied to clipboard

C# Example for adding file attachment does not work and creates confusion for end-user.

Open Shweta-1405 opened this issue 2 years ago • 3 comments

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 -

  1. '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.

  2. 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.

Shweta-1405 avatar May 08 '23 10:05 Shweta-1405