It is difficult to derive the C# code from the HTTP example.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
In addition the update example uses a string type for the stream, which isn't the right-type. Showing loading a file stream or converting the text to the stream as a complete example would be more useful.
Also related to #3902 about setting the proper file type for upload should be part of this sample.
Please add a c#/non-http example for uploading a NEW file with microsoft graph. Not sure why it's been a month and still no documentation is provided
@angelinatquach in case it is useful and you have not noticed it, here is a working code snippet for both small and large files:
https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3097#issuecomment-577906540
@zipswich your example only seems to reference updating an existing file, since your snippet always requires an item ID
.Items[diameraAlternativeRoll.Id]
I want to upload a NEW file, so I wouldn't know the item id
@angelinatquach diameraAlternativeRoll.Id is the id of an existing folder where a file will be uploaded.
@zipswich is the existing folder the same thing as a drive?
This is the error I get. However, I use the same driveID to get the files, and I can see them...
Microsoft.Graph.ServiceException: Code: itemNotFound
Message: The resource could not be found.
Inner error:
AdditionalData:
request-id: 6e8fc193-3e4e-49ff-98d8-dee3d853e173
date: 2/26/2020 1:31:18 AM
ClientRequestId: 6e8fc193-3e4e-49ff-98d8-dee3d853e173
@angelinatquach No. It is a folder under OneDrive. Here is the code to get it:
DriveItem diameraAlternativeRoll = null;
IDriveItemChildrenCollectionPage children = await provider.Graph.Me.Drive.Root.Children
.Request()
.GetAsync();
diameraAlternativeRoll = children.First(r => r.Name == "Camera Alternative roll");
thank you!!! This worked so good, I really appreciate it @zipswich
Most helpful comment
In addition the update example uses a string type for the stream, which isn't the right-type. Showing loading a file stream or converting the text to the stream as a complete example would be more useful.
Also related to #3902 about setting the proper file type for upload should be part of this sample.