SOLVED

SharePoint Online CSOM for creating Site Collection App Catalog

%3CLINGO-SUB%20id%3D%22lingo-sub-160865%22%20slang%3D%22en-US%22%3ESharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-160865%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%0A%3CP%3EI%20know%20that%20there%20is%20PowerShell%20cmdlets%20to%20create%20and%20remove%20site%20collection%20app%20catalog.%20Question%20is%20are%20there%20CSOM%20APIs%20available%20to%20do%20the%20same%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-378416%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-378416%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F369%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3Ei%20am%20facing%20similar%20problem%2C%20i%20need%20to%20create%20tenant%20app%20catalog%20site%20by%20code%20(CSOM%20for%20my%20case).%3C%2FP%3E%3CP%3EYour%20solution%20works%20if%20that%20site%20exists%20and%20adds%20particular%20existing%20site%20as%20an%20app%20catalog%20site.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EWeb.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(this.Site.Url)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EBut%20i%20need%20to%20create%20tenant%20app%20catalog%20site%20and%20i%20couldn't%20find%20any%20solution%20to%20do%20that%20by%20any%20api.%20Is%20there%20a%20solution%20for%20that%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166355%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166355%22%20slang%3D%22en-US%22%3E%3CP%3EI%20confirm%20that%20below%20code%20works%20as%20expected.%20I%20used%20SharePoint%20App%20credentials%20which%20has%20permissions%20on%20tenant%20to%20execute%20the%20code%20and%20its%20working%20as%20expected.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20Vesa!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Eusing%20(ClientContext%20clientContext%20%3D%20authManager.GetClientContextWithAccessToken(siteURL))%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clientContext.Load(clientContext.Web)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clientContext.ExecuteQuery()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clientContext.Web.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(siteURL)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clientContext.Web.Update()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clientContext.ExecuteQuery()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20catch%20(Exception%20ex)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Console.WriteLine(%22Exception%3A%20%22%20%2B%20ex.ToString())%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-166332%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-166332%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Vesa!%20I%20will%20give%20a%20try%20and%20update%20you%20if%20it%20helps.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-165243%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-165243%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3Eyou%20should%20be%20able%20to%20do%20that%20with%20following%20CSOM%26nbsp%3Bcommands%20as%20long%20as%20you%20are%20using%20relatively%20new%20CSOM%20NuGet%20version.%20You%20will%20need%20to%20have%20owner%20privileges%26nbsp%3Bto%20the%20tenant%20app%20catalog%20site%20collection%20to%20make%20this%20call.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWeb.TenantAppCatalog.SiteCollectionAppCatalogsSites.Add(this.Site.Url)%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-161987%22%20slang%3D%22en-US%22%3ERE%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-161987%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F369%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%20-%20Any%20insight%20on%20this%20would%20be%20appreciated.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-452292%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-452292%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20is%20currently%20no%20CSOM%20to%20create%20app%20catalog%20for%20a%20tenant.%20We%20are%20potentially%20looking%20into%20making%20this%20happen%20by%20the%20end%20of%202019.%20No%20exact%20ETA%20though%20at%20this%20point.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1005291%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1005291%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F369%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%26nbsp%3B%3A%20Do%20you%20have%20an%20update%20on%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20there%20still%20plans%20to%20include%20this%20in%20CSOM%3F%20If%20not%2C%20is%20there%20an%20option%20to%20create%20a%20tenant%20app%20catalog%20using%20PowerShell%20or%20CLI%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1008204%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20CSOM%20for%20creating%20Site%20Collection%20App%20Catalog%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1008204%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F456618%22%20target%3D%22_blank%22%3E%40florianwachter%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlans%20still%20do%20exists%2C%20but%20no%20ETA.%20Having%20an%20API%20to%20make%20this%20happen%20is%20also%20pre-requisite%20for%20supporting%20it%20in%20PowerShell%20or%20in%20CLI%2C%20as%20they%20will%20be%20then%20calling%20that%20API.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional 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
Highlighted
@Vesa Juvonen - Any insight on this would be appreciated.
Highlighted
Best Response confirmed by Rahul Suryawanshi (Occasional 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);

Highlighted

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

Highlighted

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

            }

 

Highlighted

@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?

Highlighted

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.

Highlighted

@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

Highlighted

@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.