SOLVED

SharePoint Online CSOM for creating Site Collection App Catalog

Copper Contributor

Hi All,

I know that there is PowerShell cmdlets to create and remove site collection app catalog. Question is are there CSOM APIs available to do the same?

8 Replies
@Vesa Juvonen - Any insight on this would be appreciated.
best response confirmed by Rahul Suryawanshi (Copper Contributor)
Solution

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);

Thanks Vesa! I will give a try and update you if it helps.

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());
                }
                

            }

 

@Vesa Juvonen 

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?

There is currently no CSOM to create app catalog for a tenant. We are potentially looking into making this happen by the end of 2019. No exact ETA though at this point.

@Vesa Juvonen : Do you have an update on this?

 

Are there still plans to include this in CSOM? If not, is there an option to create a tenant app catalog using PowerShell or CLI?

 

Thanks

@florianwachter 

 

Plans still do exists, but no ETA. Having an API to make this happen is also pre-requisite for supporting it in PowerShell or in CLI, as they will be then calling that API. 

1 best response

Accepted Solutions
best response confirmed by Rahul Suryawanshi (Copper Contributor)
Solution

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);

View solution in original post