Forum Discussion
SharePoint Online CSOM for creating Site Collection App Catalog
- Feb 26, 2018
Hi,
you should be able to do that with following CSOM commands as long as you are using relatively new CSOM NuGet version. You will need to have owner privileges to the tenant app catalog site collection to make this call.
Web.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(this.Site.Url);
- VesaJuvonenFeb 26, 2018
Microsoft
Hi,
you should be able to do that with following CSOM commands as long as you are using relatively new CSOM NuGet version. You will need to have owner privileges to the tenant app catalog site collection to make this call.
Web.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(this.Site.Url);
- tcelebiogluMar 21, 2019Copper Contributor
Hi,
i am facing similar problem, i need to create tenant app catalog site by code (CSOM for my case).
Your solution works if that site exists and adds particular existing site as an app catalog site.
Web.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(this.Site.Url);
But i need to create tenant app catalog site and i couldn't find any solution to do that by any api. Is there a solution for that?
- Rahul SuryawanshiFeb 28, 2018Copper Contributor
I confirm that below code works as expected. I used SharePoint App credentials which has permissions on tenant to execute the code and its working as expected.
Thanks Vesa!
using (ClientContext clientContext = authManager.GetClientContextWithAccessToken(siteURL)) { try { clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); clientContext.Web.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(siteURL); clientContext.Web.Update(); clientContext.ExecuteQuery(); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } } - Rahul SuryawanshiFeb 28, 2018Copper Contributor
Thanks Vesa! I will give a try and update you if it helps.