Jerry
Jerry

Reputation: 63

Download files from SharePoint using .NET Core 6

I have been looking into online materials (mainly .NET SDKs) to help me with open SharePoint folders and download all/some of the files based on filters using .NET Core. I could see some posts with graph APIs [eg: https://blog.josephvelliah.com/download-sharepoint-file-using-microsoft-graph-api].

Is there any .NET Core 6 compatible SDK available from Microsoft to do this?

I have tried to use Graph APIs but looking for SDK from Microsoft to do this

Upvotes: 2

Views: 1909

Answers (1)

Nelson Nyland
Nelson Nyland

Reputation: 555

The Microsoft Graph API has an SDK out of the box that works for .NET Core 6 and above. Here is a link to get you started:

https://learn.microsoft.com/en-us/graph/tutorials/dotnet?tabs=aad

After figuring out authentication, I would recommend looking at their documentation on downloading files:

// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Content.GetAsync();

https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=csharp

Accessing SharePoint requires a SiteID and a DriveID - they are readily available when you sign-in to the Graph API Explorer:

https://developer.microsoft.com/en-us/graph/graph-explorer

Upvotes: 0

Related Questions