Skip to content

Installing SPFX App in Tenant site #483

@MunojKannan

Description

@MunojKannan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions