Reputation: 11
I'm working on a .NET6 web api, and i use the pnp framework in order to provision remotely SharePoint templates to client tenant, for the templates i store them in a SharePoint library and i want to access them.
i tried this code for that but i got an error on GetTemplate("PnPProvisioningDemo.xml") method: The Provisioning Template URI PnPProvisioningDemo.xml is not valid. i tried to search in documentation but nothing found.
is there another way to load template from sharepoint library or fix the current issue, Thank you.
using (var context = new ClientContext("https://11h33g.sharepoint.com"))
{
context.ExecutingWebRequest += (sender, args) =>
{
args.WebRequestExecutor.RequestHeaders["Authorization"] = "Bearer " + accessToken;
};
// Load the template from the SharePoint library
var provider = new XMLSharePointTemplateProvider(context, "https://11h33g.sharepoint.com/sites/devanddep", "Documents");
ProvisioningTemplate template = provider.GetTemplate("PnPProvisioningDemo.xml");
// Apply the template to the SharePoint site
ctx.Web.ApplyProvisioningTemplate(template);
}
Upvotes: 1
Views: 213