pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Import-PnPTermGroupFromXml "The Provided template is not valid" #2303

Open IrCheema opened 4 years ago

IrCheema commented 4 years ago

Hi, I am running SharePointPnPPowerShell2016 (3.14.1910.0), and trying to create termsets with child terms inside a Term group. But keep geting "The Provided template is not valid". The template is created using Export-PnPTermGroupToXml. I have double checked the group ID as well. However same cmdlet works fine on dev server which is runing SharePointPnPPowerShell2016 (3.13.1909.0) both with -Path parameter and -Xml parameter

VM: Windows Server 2016

Expected behavior

Term structure in the xml file or xml variable should be created under Term group

Actual behavior

Import-PnPTermGroupFromXml : The provided template is not valid!
At line:1 char:1
+ Import-PnPTermGroupFromXml -Path c:\Users\xxxxxx\Documents\Navig ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Import-PnPTermGroupFromXml], ApplicationException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Taxonomy.ImportTermGroupFromXml

Steps to reproduce behavior

  1. User: Termstore owner
  2. Run Powershell as Admin
  3. Run command
    
    Import-PnPTermGroupFromXml -Path c:\prodterms.xml

OR

$xml = '

' Import-PnPTermGroupFromXml -Xml $xml ``` ### Which version of the PnP-PowerShell Cmdlets are you using? SharePointPnPPowerShell2016 (3.14.1910.0) ### What is the version of the Cmdlet module you are running? 3.14.1910.0 ### How did you install the PnP-PowerShell Cmdlets? - [ ] Installed through the PowerShell Gallery with Install-Module
ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

westerdaled commented 4 years ago

Hi I am also having this issue whilst trying to import a term group from our live tenant to our test tenant

`Set-PnPTraceLog -On -LogFile traceoutput.txt -Level Debug
$termGroupName = "MyCLient - health and wellbeing contractor Services"
$termGroupFilename = ($termGroupName + ".xml")
Export-PnPTermGroupToXml -Out $termGroupFilename -Identity $termGroupName
# connect to test tenant ( admin site) . also change UPNs to match destination tenant
Import-PnPTermGroupFromXml -Path $termGroupFilename

Tracelog error

powershell.exe Error: 0 : 2019-10-23 13:26:40.5435 [SchemaFormatter] [0] [Error] Template is not valid: The element 'Office365GroupsSettings' in namespace 'http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema' has incomplete content. List of possible elements expected: 'Property' in namespace 'http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema'. 0ms

Kind of weird as Office365GroupSettings is an optional tenant level setting whereas i am just looking a term group.

maheralawadhi commented 4 years ago

I have the exact same issue. I work on SP Online, and my PnP Cmdlet module version is 3.14.1910.0.

toblum commented 4 years ago

I can confirm the behavior too. It would be nice if this could be repaired soon.

Best regards Tobias

westerdaled commented 4 years ago

I have stopped seeing this issue . In my case exporting and importing term groups from the live to the test tenant using the code snippet I posted above. In both case I have used the -UseWebLogin to connect but this shouldn't be relevant.

Get-InstalledModule -Name SharePointPnPPowerShellOnline | fl Version

Version : 3.15.1911.0
dylanhayes commented 4 years ago

I was still getting the same issue myself. I tried both exporting from my own tenants, and with an export from somebody elses tenant where the process worked. In both cases, it fails with Import-PnPTermGroupFromXml : Template is not valid My version is 3.15.1911.0 The debug message is The element 'ProvisioningTemplate' in namespace 'http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema' has invalid child element 'Objects'. List of possible elements expected: 'WebSettings, ClientSidePages, SearchSettings, Pages, Security, Footer, Properties, SiteWebhooks, Lists, ProvisioningTemplateWebhooks, Workflows, ComposedLook, SitePolicy, SiteFields, RegionalSettings, AuditSettings, Theme, ContentTypes, Files, Navigation, CustomActions, SiteSettings, ApplicationLifecycleManagement, Publishing, Providers, SupportedUILanguages, TermGroups, Header, PropertyBagEntries, Features' in namespace 'http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema'. 0ms

Following a suggestion from a coworker, I refactored the code to store the generated XML as a variable, rather than save the file, at which point it worked. So it looks like there may be a issue with encoding of the file, but you can work around this by keeping the XML in memory. By forcing a particular encoding rather than the default unicode this may resolve the problem, but I haven't tried this.

Attachments are my trivial example code (with extension changed to txt) and the debug output. traceoutput.txt termset.xml.txt

garrytrinder commented 4 years ago

I've been looking into this this morning as a customer had reported this issue using the latest version on PnP (January 2020).

I tested on an older version, 3.14 and the issue remains, luckily we know the exact version which did work, reverting back to 3.10.1906.0 and the XML file is imported with no issues. So something happened between 3.10 and 3.14 causing this issue.

garrytrinder commented 4 years ago

This isn't a permanent fix, but is a quick solution to the problem when running the latest version, 3.17.2001.2.

Updating the XML schema from <pnp:TermGroups xmlns:pnp="http://schemas.dev.office.com/PnP/2019/03/ProvisioningSchema"> to <pnp:TermGroups xmlns:pnp="http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema"> worked for me.

petepuu commented 4 years ago

I have this same issue using newest version 3.19.2003.0. Tried to change to schema @garrytrinder suggested but it didn't work for me.

https://github.com/pnp/PnP-PowerShell/issues/2040#issuecomment-610869228

westerdaled commented 4 years ago

This issue issue just won't go away 😣. I am using 3.21.2005.1' and I am trying to import a term group from React Application-regions-footer sample <xmlns:pnp="http://schemas.dev.office.com/PnP/2018/07/ProvisioningSchema"> to <pnp:TermGroups xmlns:pnp="http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema"> did not work for me. Import-PnPTermGroupFromXml : Template is not valid

At line:1 char:1

  • Import-PnPTermGroupFromXml -Path .\GeoGroups.xml
  • 
    + CategoryInfo          : WriteError: (:) [Import-PnPTermGroupFromXml], ApplicationException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Taxonomy.ImportTermGroupFromXml
westerdaled commented 4 years ago

If you then change the schema to

<pnp:TermGroups xmlns:pnp="http://schemas.dev.office.com/PnP/2020/02/ProvisioningSchema">

You now get a new error but still no termgroup import 🤨

Import-PnPTermGroupFromXml -Path .\GeoGroups.xml Import-PnPTermGroupFromXml : Access denied. You do not have permission to perform this action or access this resource. At line:1 char:1

  • Import-PnPTermGroupFromXml -Path .\GeoGroups.xml I am a GA for this tenant and got the schema by sucessfully exporting a test term group and termset. Oh well .
rrocham commented 4 years ago

Just wanted to mention in this thread that I was also getting access denied with the Import-PnPTermGroupFromXml.

What fixed for me was to use the -UseWebLogin switch in the connect command even though I don't have MFA enabled for my user. (it was enabled at some point but disabled later so I'm not sure if that affected my user)

shrirampophali commented 4 years ago

Tried all the options but still getting "The provided template is not valid!" error. also tried exporting schema and using that while import but no use. Can someone please post here working example of Import Term Group Schema?

westerdaled commented 4 years ago

@shrirampophali , I have just sucessfully tried an export and import of the attached termgroup.xml file ( inspired by reading the BBC news 😀) . You will need to search and replace my account with your own account.

PartyLeaders.zip

shrirampophali commented 4 years ago

Thanks a lot @westerdaled for your help! 👍 Actually it finally worked with this