Thursday, 28 March 2019

Programmatically get list of applications added by AppRegNew.aspx in SharePoint Online using CSOM

SHARE

To look up registration information for an add-in that you have registered, go to http://<SharePointWebsite>/_layouts/15/AppInv.aspx.
 Code Snippet:
using (ClientContext context = new ClientContext("http://weburl/"))
            {
                Web web = context.Web;
                web.Context.Load(web);
                web.Context.ExecuteQuery();

                // Get all Add-ins installed on the web
                var addInInstance = AppCatalog.GetAppInstances(context, web);
                addInInstance.Context.Load(addInInstance);
                addInInstance.Context.ExecuteQuery();

                foreach (var appInstance in addInInstance)
                {

                    //Check whether it is Remote hosted Add-in
                    if (string.IsNullOrEmpty(appInstance.AppWebFullUrl))
                    {
                        Console.WriteLine("This is a remote hosted add-in");
                        // You can now get all the information about your appInstance object
                        Console.WriteLine("Add-in Title: " + appInstance.Title);
                        Console.WriteLine("Status: " + appInstance.Status);
                        Console.WriteLine("Start Page: " + appInstance.StartPage);
                        Console.WriteLine("Add-in Id: " + appInstance.Id);
                    }
                }
            }



SHARE

Author: verified_user

0 Comments: