SharePoint Online: "Access denied. You do not have permission to perform this action or access this resource" Error on Uploading File, Creating Folder in Style Library

Problem:  Getting "Access Denied. You do not have permission to perform this action or access this resource" Error when trying to upload a File or creating folder in "Style Library".

Access denied. You do not have permission to perform this action or access this resource.

Also we get the similar error when trying to create a new folder:

access denied error on creating a folder style library


Solution:

This is because Custom script is disabled for the site collection. To fix the issue, we have to enable custom script for the particular site collection. In modern team sites and communication sites, custom script is disabled by default.


How to Enable Custom Script in SharePoint Online?
Here is how to enable custom script in SharePoint Online:
  • Login to SharePoint Online Admin Center
  • Click on Settings from the left navigation >> Click on "Classic Site Settings" link (https://tenant-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx) and Scroll down to "Custom Script" section.
  • Set "Allow users to run custom script on personal site" and "Allow users to run custom script on self-service created sites" options. 
    sharepoint online save site as template error
  • Click on "OK" to save your changes.
This enables custom script in SharePoint Online. However, this change may take up to 24 Hours to reflect. To enable scripting on a particular site collection immediately, use this PowerShell script in SharePoint Online Management Shell.

PowerShell to Fix Access Denied Error on uploading Files in SharePoint Online Issue:
Use this PowerShell script to enable custom scripting instantly.
#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com/sites/marketing"
 
#Get Credentials to connect
$Cred = Get-Credential
 
#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred
 
#Disable DenyAddAndCustomizePages Flag
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False

This fixes the "Access denied. You do not have permission to perform this action or access this resource" Error on Uploading File or creating new folder in Style Library in SharePoint Online site collection. 


Here is my another article on enabling custom script in SharePoint Online: How to Enable Custom Script in SharePoint Online?

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.