Invoke-PnPSiteTemplate gives Object reference not set to an instance of an object error
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 259
- Forks
- 161
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
PnP.PowerShell version used 1.9.0
I am trying to input a page template into a site using Invoke-PnPSiteTemplate -Path C:\template.xml but I get the Object reference not set to an instance of an object error. This following is what it says:
Object reference not set to an instance of an object.
Stacktrace : at PnP.Framework.Provisioning.ObjectHandlers.ObjectClient
SidePages.CreatePage(Web web, ProvisioningTemplate
template, TokenParser parser, PnPMonitoredScope scope,
BaseClientSidePage clientSidePage, String pagesLibrary,
List pagesLibraryList, Int32& currentPageIndex, List`1
preCreatedPages)
at PnP.Framework.Provisioning.ObjectHandlers.ObjectClient
SidePages.ProvisionObjects(Web web, ProvisioningTemplate
template, TokenParser parser,
ProvisioningTemplateApplyingInformation applyingInformation)
at PnP.Framework.Provisioning.ObjectHandlers.SiteToTempla
teConversion.ApplyRemoteTemplate(Web web,
ProvisioningTemplate template,
ProvisioningTemplateApplyingInformation provisioningInfo,
Boolean calledFromHierarchy, TokenParser tokenParser)
at PnP.PowerShell.Commands.Provisioning.Site.InvokeSiteTe
mplate.ExecuteCmdlet()
at
PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord()
I can't figure out what is wrong as it seems to work in my other tenant which is also using PnP.Powershell version 1.9.0. The following is the xml in question
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
<pnp:Preferences Generator="PnP.Framework, Version=1.7.3.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" />
<pnp:Templates ID="CONTAINER-TEMPLATE-2B491D07795F46BF9549DEB0DD1F4382">
<pnp:ProvisioningTemplate ID="TEMPLATE-2B491D07795F46BF9549DEB0DD1F4382" Version="1" BaseSiteTemplate="SITEPAGEPUBLISHING#0" Scope="RootSite">
<pnp:ClientSidePages>
<pnp:ClientSidePage PromoteAsNewsArticle="false" PromoteAsTemplate="false" Overwrite="true" Title="News Temp" ContentTypeID="0x0101009D1CB255DA76424F860D91F20E6C411800A4D7037E80DD6548B6D85085F1A3993F01" ThumbnailUrl="" PageName="Templates/News-article5.aspx">
<pnp:Header Type="Custom" ServerRelativeImageUrl="https://{fqdn}{site}/SiteAssets/SitePages/News-Temp/picture.jpg" LayoutType="CutInShape" ShowTopicHeader="false" ShowPublishDate="false" TopicHeader="" AlternativeText="" Authors="[]" AuthorByLine="[]" AuthorByLineId="-1" />
<pnp:Sections>
<pnp:Section Order="1" Type="TwoColumnLeft">
<pnp:Controls>
<pnp:CanvasControl WebPartType="Text" ControlId="1212fc8d-dd6b-408a-8d5d-9f1cc787efbb" Order="1" Column="1">
<pnp:CanvasControlProperties>
<pnp:CanvasControlProperty Key="Text" Value="<br>" />
</pnp:CanvasControlProperties>
</pnp:CanvasControl>
<pnp:CanvasControl WebPartType="Image" JsonControlData="{"id": "d1d91016-032f-456d-98a4-721247c305e8", "instanceId": "c5beaece-386f-421c-889d-b46e064f38a3", "title": "Image", "description": "Add an image, picture or photo to your page including text overlays and ability to crop and resize images.", "dataVersion": "1.9", "properties": {"imageSourceType":0,"imageSource":"","captionText":"","altText":"","linkUrl":"","overlayText":"","fileName":"","siteId":"","webId":"","listId":"","uniqueId":"","imgWidth":"","imgHeight":"","alignment":"Center"}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="d1d91016-032f-456d-98a4-721247c305e8" Order="1" Column="2" />
<pnp:CanvasControl WebPartType="DocumentEmbed" JsonControlData="{"id": "b7dd04e1-19ce-4b24-9132-b60a1c2b910d", "instanceId": "ca93deb3-7205-4ca8-aeca-717cfbab576f", "title": "File viewer", "description": "Display a document or file on your page including Word, Excel, PowerPoint, PDF, 3D models, videos, and more.", "dataVersion": "1.4", "properties": {"annotation":"","authorName":"","chartitem":"","endrange":"","excelSettingsType":"","file":"","listId":"","modifiedAt":"","photoUrl":"","rangeitem":"","serverRelativeUrl":"","siteId":"","startPage":1,"startrange":"","tableitem":"","title":"","uniqueId":"","wdallowinteractivity":true,"wdhidegridlines":true,"wdhideheaders":true,"webId":"","wopiurl":""}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="b7dd04e1-19ce-4b24-9132-b60a1c2b910d" Order="2" Column="2" />
</pnp:Controls>
</pnp:Section>
</pnp:Sections>
</pnp:ClientSidePage>
</pnp:ClientSidePages>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Invoke-PnPSiteTemplate failure with the supplied template XML and inspect the PnP.Framework.Provisioning.ObjectHandlers.ObjectClientSidePages.CreatePage stack-trace entry. Compare the failing tenant and the working tenant, then identify the null object and add coverage showing that applying this client-side page template completes without the exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100