Forum Discussion
Jacqui Hurst
Feb 20, 2024Copper Contributor
Invoke-RestMethod Upload a File to Sharepoint 401 error
Hi Please help. I have tried many different scripts (taken from the Internet and modified) to try and upload a file to a Sharepoint library but I keep leading myself back to the same issue of a...
- Mar 01, 2024I took a step back and started again and after a little more research I found a method that works. I moved away from Client Secret to a certificate and used PNP.Powershell. There is loads of work in getting this running but at least I have an unattended script now.
$tenant = “xxxxxxx”
$url = "https://$tenant.sharepoint.com/sites/ITandSoftware"
$file = "c:\temp\test.txt"
$ClientID = "xxxxxxxxxxxxxx"
$CertThumb = 'xxxxxxxxxxxxxxxxxx'
Connect-PnPOnline $url -ClientId $ClientID -Tenant $tenant.onmicrosoft.com -Thumbprint $CertThumb
Add-PnPFile -folder "Shared Documents/Calls" -path $file
I thought I would share in case anyone wanted to know the conclusion.
Thanks for responses though, it helps to know there is some help out there when needed.
flipq
Feb 22, 2024Copper Contributor
Awsome