Sitecollection App Catalog error: Cannot find resource for the request

Please note that deploy to SharePoint sitecollection app catalog using the ALM apis is still not officially announced and in BETA. So, failing that service should expected, but I still use it to experiment from time to time in our first release tenant where it is partially working.

Perhaps recent changes to the SP.RequestContext.curr ent/web/sitecollectionappcatalog made the endpoint cause errors:


{"error":{"code":"-1, Microsoft.SharePoint.Client.ResourceNotFoundException","message":{"lang":"en-US","value":"Cannot find resource for the request SP.RequestContext.curr
ent/web/sitecollectionappcatalog/."}}}


To work around that because we use it to deploy to multiple sites I implemented a simple retry logic, so it will try to deploy few times. This Powershell function using the SharePoint PnP PowerShell and retry logic works for me so far.



function AddApp($SiteFullUrl, $Creds, $PackagePath) {

$stopLoop = $false
$retryCount = 0
do {
try {

Connect-PnPOnline $SiteFullUrl -Credentials $Creds

Add-PnPApp -Path $PackagePath -Scope Site -Publish -Overwrite -SkipFeatureDeployment -ErrorAction Stop
Write-Host $("ProvisioningCommon:AddApp: Job completed for " + $PackagePath)

$stopLoop = $true
}
catch [Exception] {
if ($retryCount -gt 30){
Write-Host $("ProvisioningCommon:AddApp: Max retry for " + $PackagePath)
$stopLoop = $true
}
else {
Write-Host $_.Exception.Message -ForegroundColor Yello
Write-Host $("ProvisioningCommon:AddApp: Could not complete retrying in 10 seconds... " + $PackagePath)
Start-Sleep -Seconds 10
$retryCount = $retryCount + 1
}
}
} while ($stopLoop -eq $false)
}


Here is the outcome, when the PnP PowerShell function is run.


CreateBusinessProfile:Add solution packages
{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.ResourceNotFoundException","message":{"lang":"en-US","value":"Cannot find resource for the request SP.RequestContex
t.current/web/sitecollectionappcatalog/."}}}
ProvisioningCommon:AddApp: Could not complete retrying in 10 seconds... .\packages\xxx-vision-bu.sppkg
{"error":{"code":"-1, Microsoft.SharePoint.Client.ResourceNotFoundException","message":{"lang":"en-US","value":"Cannot find resource for the request SP.RequestContext.curr
ent/web/sitecollectionappcatalog/."}}}
ProvisioningCommon:AddApp: Could not complete retrying in 10 seconds... .\packages\xxx-vision-bu.sppkg
Id : 57d2522d-11c3-46b9-9a99-9e11a1ddfc45
AppCatalogVersion : 18.7.9.3
CanUpgrade : False
Deployed : True
InstalledVersion :
IsClientSideSolution : True
Title : xxx-vision-bu

ProvisioningCommon:AddApp: Job completed for .\packages\xxx-vision-bu.sppkg


Conclusion


The deploy to SharePoint site collection app catalog ALM APIs are still not ready for real usage. You can use this retry function to experiment, but not in production. Let's wait and see if Microsoft will make that officially available soon.