Microsoft.SharePoint.Client.ResourceNotFoundException type not found

DevAsith 41 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)
{

}

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,034 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,619 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,091 Reputation points Microsoft Vendor
    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.