Could not upload to the storage location the remote server returned an error 403 forbidden?
Error: Exception calling “ExecuteQuery” with “0” argument(s): “The remote server returned an error: (403) Forbidden.” in PowerShell scripts for SharePoint Online. Follow this checklist to resolve Executequery 403 forbidden error in SharePoint Online PowerShell: #Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#parameters
$SiteURL = "https://Crescent.sharepoint.com"
$UserName = "[email protected]"
$Password = "Password goes here"
$SecurePassword= $Password | ConvertTo-SecureString -AsPlainText -Force
#Setup the Context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
$Ctx.Credentials = $Cred
#Get the Site Collection storage used
$Site = $Ctx.Site
$Ctx.Load($Site)
$Site.Retrieve("Usage")
$ctx.ExecuteQuery()
$StorageUsed = [Math]::Round(($Site.Usage.Storage/1MB),2)
#Get Site Collection Size
Write-host "Storage Used: $StorageUsed MB"
$TenantAdminURL = "https://crescent-admin.sharepoint.com/sites/london"
#Connect to the Site
Connect-PnPOnline -URL $TenantAdminURL -Interactive
Get-PnPSite
Salaudeen RajackSalaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles! I am getting the following error when trying to upload files to the Azure blob storage. This was working fine before. Does anyone know why it would return a 403 Forbidden message? I am using C# in ASP.NET MVC and have installed the client library for Windows Azure Storage.
asked Aug 3, 2017 at 18:51
Prithvi RamanaPrithvi Ramana 2011 gold badge4 silver badges12 bronze badges 3 According to the 403 exception, it seems that you have no access to the container.
If you are using Azure storage account key to access the resource, please have a try to make sure that account key is not changed or you could regenerate it and try it again. If you are using Service SAS, please have a try to make sure that it is not out of date. You also could use Azure portal or Microsoft Azure Storage Explorer to regenerate SAS token and try it again. Update: According to the comment: Azure storage also support CORS, more detail please refer to document. We also could set CORS from azure portal, please refer to the screenshot. answered Aug 4, 2017 at 1:20
Tom Sun - MSFTTom Sun - MSFT 23.4k3 gold badges26 silver badges43 bronze badges 7 Not the answer you're looking for? Browse other questions tagged c# asp.net-mvc azure azure-storage azure-blob-storage or ask your own question.How do I fix the remote server returned an error 403 Forbidden?This problem usually happens when the computer is using the Proxy/VPN. Please disable the Proxy/VPN temporary and try again. If you're using the Proxy Settings in Driver Easy, please go to the Settings panel and set it to Use default browser settings.
Why does one drive say 403 Forbidden?The “403 Forbidden” error might occur because of one of the following conditions: Your browser cache has to be cleared. Your permissions to the file haven't replicated correctly on the server. Your OneDrive site is locked.
|