3

I have been trying hard to find any example, resource which explains how to get a list of installed apps in SharePoint 2013 environment using Client Object Model. So far I have found nothing.

Could you please share some links if you happen to know any that explains:

  1. How to get list of apps installed in a SharePoint 2013 web using SP2013 Managed Client Object Model.
  2. How to get list of apps installed in a SharePoint 2013 web using either WCF or REST service. -- I would really like to know how to do this as I need to create a WebPart in SP 2010 that lists apps installed in our SP 2013 Office 365 env.
3

Use AppCatalog class for this. Proof of concept below:

class StackExchangeProof
{
    static void Main(string[] args)
    {
        var login    = "admin@yourdomain.onmicrosoft.com";
        var password = "YourHardP@ssw0rd";
        var url      = "https://yourdomain.sharepoint.com";

        var creds  = new SharePointOnlineCredentials(login, ToSecureString(password));

        using (var context = new ClientContext(url))
        {
            context.Credentials = creds;

            var apps = AppCatalog.GetAppInstances(context, context.Web);
            context.Load(apps);
            context.ExecuteQuery();

            foreach (var app in apps)
            {
                Console.WriteLine("App Name: {0} - {1}", app.Title, app.Status);
            }
        }
    }

    public static SecureString ToSecureString(string source)
    {
        if (string.IsNullOrWhiteSpace(source))
            return null;

        var result = new SecureString();
        foreach (char c in source)
            result.AppendChar(c);

        return result;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.