Microsoft.SharePoint.Client.ResourceNotFoundException type not found

DevAsith 51 Reputation points
2021-08-03T10:16:07.9+00:00

I am getting following error while using [https://github.com/pnp/pnpframework] and I want to specifically catch this error.
But there is no such a type 'Microsoft.SharePoint.Client.ResourceNotFoundException' , is there way to handle this error ?

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

try
{
var appMetadata = appManager.Add(filePath, true, AppCatalogScope.Site);
if (appManager.Deploy(appMetadata.Id, false, AppCatalogScope.Site)) {...}
}
catch (Exception ex)
{

}

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2021-08-04T09:03:58.08+00:00

    Hi @DevAsith ,
    If it fails at the Get-PnPApp step already, it most probably means you connected to a site using Connect-PnPOnline for which you have not explicitly enabled the site collection app catalog feature. Follow the steps in this document :
    https://learn.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog#configure-and-manage-site-collection-app-catalogs


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.