pnp / pnp/pnpframework

Invoke-PnPSiteTemplate gives Object reference not set to an instance of an object error

Open
#581 2 comments 0 reactions 0 assignees View on GitHub

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="&lt;br&gt;" />
                  </pnp:CanvasControlProperties>
                </pnp:CanvasControl>
                <pnp:CanvasControl WebPartType="Image" JsonControlData="{&quot;id&quot;: &quot;d1d91016-032f-456d-98a4-721247c305e8&quot;, &quot;instanceId&quot;: &quot;c5beaece-386f-421c-889d-b46e064f38a3&quot;, &quot;title&quot;: &quot;Image&quot;, &quot;description&quot;: &quot;Add an image, picture or photo to your page including text overlays and ability to crop and resize images.&quot;, &quot;dataVersion&quot;: &quot;1.9&quot;, &quot;properties&quot;: {&quot;imageSourceType&quot;:0,&quot;imageSource&quot;:&quot;&quot;,&quot;captionText&quot;:&quot;&quot;,&quot;altText&quot;:&quot;&quot;,&quot;linkUrl&quot;:&quot;&quot;,&quot;overlayText&quot;:&quot;&quot;,&quot;fileName&quot;:&quot;&quot;,&quot;siteId&quot;:&quot;&quot;,&quot;webId&quot;:&quot;&quot;,&quot;listId&quot;:&quot;&quot;,&quot;uniqueId&quot;:&quot;&quot;,&quot;imgWidth&quot;:&quot;&quot;,&quot;imgHeight&quot;:&quot;&quot;,&quot;alignment&quot;:&quot;Center&quot;}, &quot;serverProcessedContent&quot;: {&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{},&quot;links&quot;:{}}, &quot;dynamicDataPaths&quot;: {}, &quot;dynamicDataValues&quot;: {}}" ControlId="d1d91016-032f-456d-98a4-721247c305e8" Order="1" Column="2" />
                <pnp:CanvasControl WebPartType="DocumentEmbed" JsonControlData="{&quot;id&quot;: &quot;b7dd04e1-19ce-4b24-9132-b60a1c2b910d&quot;, &quot;instanceId&quot;: &quot;ca93deb3-7205-4ca8-aeca-717cfbab576f&quot;, &quot;title&quot;: &quot;File viewer&quot;, &quot;description&quot;: &quot;Display a document or file on your page including Word, Excel, PowerPoint, PDF, 3D models, videos, and more.&quot;, &quot;dataVersion&quot;: &quot;1.4&quot;, &quot;properties&quot;: {&quot;annotation&quot;:&quot;&quot;,&quot;authorName&quot;:&quot;&quot;,&quot;chartitem&quot;:&quot;&quot;,&quot;endrange&quot;:&quot;&quot;,&quot;excelSettingsType&quot;:&quot;&quot;,&quot;file&quot;:&quot;&quot;,&quot;listId&quot;:&quot;&quot;,&quot;modifiedAt&quot;:&quot;&quot;,&quot;photoUrl&quot;:&quot;&quot;,&quot;rangeitem&quot;:&quot;&quot;,&quot;serverRelativeUrl&quot;:&quot;&quot;,&quot;siteId&quot;:&quot;&quot;,&quot;startPage&quot;:1,&quot;startrange&quot;:&quot;&quot;,&quot;tableitem&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;uniqueId&quot;:&quot;&quot;,&quot;wdallowinteractivity&quot;:true,&quot;wdhidegridlines&quot;:true,&quot;wdhideheaders&quot;:true,&quot;webId&quot;:&quot;&quot;,&quot;wopiurl&quot;:&quot;&quot;}, &quot;serverProcessedContent&quot;: {&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{},&quot;links&quot;:{}}, &quot;dynamicDataPaths&quot;: {}, &quot;dynamicDataValues&quot;: {}}" 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.