0

While creating a web part page we have option to save it in these 4 locations: Site Assets, Site Pages, Document library and Form template. Using GetLimitedWebPartManager to get the web part manager and trying to restore it in the target location.

Seeing access denied error while uploading web part page in site pages but it works fine for all other location.

using something like this to upload it:

          // Upload the file to Site Pages library
        Microsoft.SharePoint.Client.File uploadFile = sitePagesLibrary.RootFolder.Files.Add(newFile);
        context.Load(uploadFile);
        context.ExecuteQuery();

Using App-Only based permission model and owner has full control permission level over site pages and token for owner is used to restore using above code.

Observation: for site pages Files.Add(newFile) function does not works instead using FileAddTemplateFile(leafUrl, TemplateFileType.ClientSidePage) create a template based file.

Microsoft.SharePoint.Client.File newFile = sitePagesLibrary.RootFolder.Files.AddTemplateFile(leafUrl, TemplateFileType.ClientSidePage);
context.Load(newFile);
context.ExecuteQuery();

But how to upload the stream in this template file that is created??

without running into Access denied issues.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.