It caused by that Custom Script is disabled in the SharePoint Online for security reasons by default.
You should enable Custom Script to remove Deny permission.
1.Go to SharePoint admin center (https://<tenant>-admin.sharepoint.com) -> Click Settings in the left navigation -> Scroll down to “Custom Script” section -> In the 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.
However, this change may take up to 24 hours to reflect. To enable Custom Script in a particular site collection immediately, please use following PowerShell through SharePoint Online Management Shell.
2.PowerShell.
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com"
$Cred = Get-Credential
Connect-SPOService -URL $AdminSiteURL -Credential $Cred
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False
Reference:
Allow or prevent custom script
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.