Forum Discussion
Uploading a file to a SharePoint Document Library Sub Folder using a C# Console Application in 2023
You are approching this the completly the wrong way, so what you need to do it use the Graph API to upload the files to the subfolder. Don't disbale MFA, registering the app in Azure AD and use those credentials.
You will need to add the correct permisisons in Azure ad:
https://learn.microsoft.com/en-us/azure/active-directory-b2c/microsoft-graph-get-started?tabs=app-reg-ga
How to use graph api in c#:
https://learn.microsoft.com/en-us/graph/sdks/create-requests?tabs=csharp
Upload files:
https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=cli
Sidenote:
From you requirements I would suggest that you use Power Auomtate instead, sounds like that could do what you aim to do.
- Dushan996Jan 02, 2024Copper ContributorThank you for your response, but we are using SharePoint in Office 365 platform (Office 365 Education). Should we still register the app in app in Azure AD in that case?
- Jan 02, 2024Yeah, it's the same not matter what version you're using 🙂 You basicly say this is the app, here's the credentials it will use and here's the permissions!
- Dushan996Jan 04, 2024Copper Contributor
Thanks a lot. Along the route, at some point it asked me to purchase a service. So I guess this is no longer possible without using a paid subscription.