none
Installing SPFX App in Tenant site

    Question

  • I am trying to install a SPFX(.sppkg) app while the site is generated. The site is created using Provider Hosted. The App was developed using CSOM and the site is developer Tenant site.

    I am trying to add the app to the site using the following code

    string path = @"~/App_Data/xxx.sppkg";

          
      // Create context for SharePoint online
            ClientContext ctx = new ClientContext(url);
            ctx.AuthenticationMode = ClientAuthenticationMode.Default;
            ctx.Credentials = new SharePointOnlineCredentials(userName, securePassword);
    
            // Get variables for the operations
            Site site = ctx.Site;
            Web web = ctx.Web;
            ctx.Load(site);
            ctx.Load(web);
            ctx.ExecuteQuery();
    
            try
            {
                // Make sure we have side loading enabled. 
                // Using PnP Nuget package extensions.
                site.Features.Add(sideloadingFeature,true,FeatureDefinitionScope.None);
                try
                {
                    string appFilePath = System.Web.Hosting.HostingEnvironment.MapPath(path);
                    // Load .app file and install that to site
                    var appstream = System.IO.File.OpenRead(appFilePath);
                    AppInstance app = web.LoadAndInstallApp(appstream);                    
                    ctx.Load(app);
                    ctx.ExecuteQuery();
                }
                 catch(Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                // Disable side loading feature using 
                // PnP Nuget package extensions. 
                site.Features.Remove(sideloadingFeature,true);
            }

    but when i tried the code above, I get the following error

    "Value cannot be null.
    Parameter name: xeAppPermissionRequests."

    This issue occurs only when adding the app using Code.

    Also we tried to add the app using the app stapling method, I get the following error.

    "Sorry, something went wrong
    An unexpected error has occurred."

    While adding the app manually(using add an app) We were able to install the app without any issue.

    But we have to do this in a programmatic way.

    Is there any way to overcome this issue ? Please suggest.

    Thanks in Advance

    Wednesday, March 15, 2017 2:04 PM

All replies

  • Hi Everybody,

    I am still stuck with this issue. Please help with a solution ASAP. I have a very tight deadline to complete this task.

    Much Appreciated.

    Thanks
    Friday, March 17, 2017 11:12 AM
  • Hi,

    Please try to set First release for everyone in admin center.

    Or try to upload the xxx.sppkg file into the app catalog, and then deploy it and check if it works.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com


    Monday, March 20, 2017 7:58 AM
    Moderator