Outdated Graph API example for uploading files to OneDrive

Bob Lan 0 Reputation points
2024-07-21T00:48:25.18+00:00
var driveItem = await serviceClient.Me.Drive.Root.ItemWithPath(itemPath).Content.Request().PutAsync<DriveItem>(stream);

https://learn.microsoft.com/en-us/training/modules/msgraph-dotnet-core-manage-files/7-upload-user-files

The example code above is no longer working with Microsoft.Graph v5.*. Can you please update it?

I tried to update it; however Request() is not defined:

await serviceClient.Drives[oneDrive!.Id].Items["root"].ItemWithPath(itemPath).Content.Request().PutAsync<DriveItem>(fileStream);

This question is related to the following Learning Module

ASP.NET Core Training
ASP.NET Core Training
ASP.NET Core: A set of technologies in the .NET Framework for building web applications and XML web services.Training: Instruction to develop new skills.
17 questions
{count} votes