cli-microsoft365: Bug report: Cannot create a new SharePoint list using example command with schemaXml option

Description

Attempts to create a new list on an existing SharePoint online team site fails with ‘Error: Invalid list template.’

Unfortunately there is no information provided in the error response from SharePoint to help determine the issue with the schemaXml.

The same issue occurs if using the schemaXml example from the documentation page, https://pnp.github.io/cli-microsoft365/cmd/spo/list/list-add/

Steps to reproduce

At an ubuntu terminal, running under wsl:

m365 spo list add --title Announcements --baseTemplate Announcements --webUrl https://watconsdev.sharepoint.com/sites/bfwvendors --schemaXml '<List xmlns:ows="Microsoft SharePoint" Title="List1" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/List1" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/"><MetaData><ContentTypes><ContentTypeRef ID="0x01"><Folder TargetName="Item" /></ContentTypeRef><ContentTypeRef ID="0x0120" /></ContentTypes><Fields><Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="$Resources:core,Title;" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" MaxLength="255" /></Fields><Views><View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE"><Toolbar Type="Standard" /><XslLink Default="TRUE">main.xsl</XslLink><RowLimit Paged="TRUE">30</RowLimit><ViewFields><FieldRef Name="LinkTitleNoMenu"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" /><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" /></ParameterBindings></View><View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/15/images/generic.png?rev=23" Url="AllItems.aspx"><Toolbar Type="Standard" /><XslLink Default="TRUE">main.xsl</XslLink><JSLink>clienttemplates.js</JSLink><RowLimit Paged="TRUE">30</RowLimit><ViewFields><FieldRef Name="LinkTitle"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name="ID"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /></ParameterBindings></View></Views><Forms><Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /><Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /><Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /></Forms></MetaData></List>'

Expected results

A new SharePoint list called Announcements is created.

Actual results

An error result is given by m365: Error: Invalid list template.

Diagnostics

Executing command spo list add with options {"options":{"debug":true,"title":"Announcements","baseTemplate":"Announcements","webUrl":"https://watconsdev.sharepoint.com/sites/bfwvendors","schemaXml":"<List xmlns:ows=\"Microsoft SharePoint\" Title=\"List1\" FolderCreation=\"FALSE\" Direction=\"$Resources:Direction;\" Url=\"Lists/List1\" BaseType=\"0\" xmlns=\"http://schemas.microsoft.com/sharepoint/\"><MetaData><ContentTypes><ContentTypeRef ID=\"0x01\"><Folder TargetName=\"Item\" /></ContentTypeRef><ContentTypeRef ID=\"0x0120\" /></ContentTypes><Fields><Field ID=\"{fa564e0f-0c70-4ab9-b863-0177e6ddd247}\" Type=\"Text\" Name=\"Title\" DisplayName=\"$Resources:core,Title;\" Required=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"Title\" MaxLength=\"255\" /></Fields><Views><View BaseViewID=\"0\" Type=\"HTML\" MobileView=\"TRUE\" TabularView=\"FALSE\"><Toolbar Type=\"Standard\" /><XslLink Default=\"TRUE\">main.xsl</XslLink><RowLimit Paged=\"TRUE\">30</RowLimit><ViewFields><FieldRef Name=\"LinkTitleNoMenu\"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name=\"Modified\" Ascending=\"FALSE\"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name=\"AddNewAnnouncement\" Location=\"Resource(wss,addnewitem)\" /><ParameterBinding Name=\"NoAnnouncements\" Location=\"Resource(wss,noXinviewofY_LIST)\" /><ParameterBinding Name=\"NoAnnouncementsHowTo\" Location=\"Resource(wss,noXinviewofY_ONET_HOME)\" /></ParameterBindings></View><View BaseViewID=\"1\" Type=\"HTML\" WebPartZoneID=\"Main\" DisplayName=\"$Resources:core,objectiv_schema_mwsidcamlidC24;\" DefaultView=\"TRUE\" MobileView=\"TRUE\" MobileDefaultView=\"TRUE\" SetupPath=\"pages\\viewpage.aspx\" ImageUrl=\"/_layouts/15/images/generic.png?rev=23\" Url=\"AllItems.aspx\"><Toolbar Type=\"Standard\" /><XslLink Default=\"TRUE\">main.xsl</XslLink><JSLink>clienttemplates.js</JSLink><RowLimit Paged=\"TRUE\">30</RowLimit><ViewFields><FieldRef Name=\"LinkTitle\"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name=\"ID\"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name=\"NoAnnouncements\" Location=\"Resource(wss,noXinviewofY_LIST)\" /><ParameterBinding Name=\"NoAnnouncementsHowTo\" Location=\"Resource(wss,noXinviewofY_DEFAULT)\" /></ParameterBindings></View></Views><Forms><Form Type=\"DisplayForm\" Url=\"DispForm.aspx\" SetupPath=\"pages\\form.aspx\" WebPartZoneID=\"Main\" /><Form Type=\"EditForm\" Url=\"EditForm.aspx\" SetupPath=\"pages\\form.aspx\" WebPartZoneID=\"Main\" /><Form Type=\"NewForm\" Url=\"NewForm.aspx\" SetupPath=\"pages\\form.aspx\" WebPartZoneID=\"Main\" /></Forms></MetaData></List>"}}
Creating list in site at https://watconsdev.sharepoint.com/sites/bfwvendors...
Existing access token eyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX still valid. Returning...
Request:
{
  "headers": {
    "common": {
      "Accept": "application/json, text/plain, */*"
    },
    "delete": {},
    "get": {},
    "head": {},
    "post": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "put": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "patch": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "user-agent": "NONISV|SharePointPnP|CLIMicrosoft365/4.2.0",
    "accept-encoding": "gzip, deflate",
    "accept": "application/json;odata=nometadata",
    "authorization": "Bearer eyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  },
  "decompress": true,
  "responseType": "json",
  "url": "https://watconsdev.sharepoint.com/sites/bfwvendors/_api/web/lists",
  "method": "post",
  "data": {
    "Title": "Announcements",
    "BaseTemplate": 104,
    "SchemaXml": "<List xmlns:ows=\\\"Microsoft SharePoint\" Title=\"List1\" FolderCreation=\"FALSE\" Direction=\"$Resources:Direction;\" Url=\"Lists/List1\" BaseType=\"0\" xmlns=\"http://schemas.microsoft.com/sharepoint/\"><MetaData><ContentTypes><ContentTypeRef ID=\"0x01\"><Folder TargetName=\"Item\" /></ContentTypeRef><ContentTypeRef ID=\"0x0120\" /></ContentTypes><Fields><Field ID=\"{fa564e0f-0c70-4ab9-b863-0177e6ddd247}\" Type=\"Text\" Name=\"Title\" DisplayName=\"$Resources:core,Title;\" Required=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"Title\" MaxLength=\"255\" /></Fields><Views><View BaseViewID=\"0\" Type=\"HTML\" MobileView=\"TRUE\" TabularView=\"FALSE\"><Toolbar Type=\"Standard\" /><XslLink Default=\"TRUE\">main.xsl</XslLink><RowLimit Paged=\"TRUE\">30</RowLimit><ViewFields><FieldRef Name=\"LinkTitleNoMenu\"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name=\"Modified\" Ascending=\"FALSE\"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name=\"AddNewAnnouncement\" Location=\"Resource(wss,addnewitem)\" /><ParameterBinding Name=\"NoAnnouncements\" Location=\"Resource(wss,noXinviewofY_LIST)\" /><ParameterBinding Name=\"NoAnnouncementsHowTo\" Location=\"Resource(wss,noXinviewofY_ONET_HOME)\" /></ParameterBindings></View><View BaseViewID=\"1\" Type=\"HTML\" WebPartZoneID=\"Main\" DisplayName=\"$Resources:core,objectiv_schema_mwsidcamlidC24;\" DefaultView=\"TRUE\" MobileView=\"TRUE\" MobileDefaultView=\"TRUE\" SetupPath=\"pages\\\\viewpage.aspx\" ImageUrl=\"/_layouts/15/images/generic.png?rev=23\" Url=\"AllItems.aspx\"><Toolbar Type=\"Standard\" /><XslLink Default=\"TRUE\">main.xsl</XslLink><JSLink>clienttemplates.js</JSLink><RowLimit Paged=\"TRUE\">30</RowLimit><ViewFields><FieldRef Name=\"LinkTitle\"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name=\"ID\"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name=\"NoAnnouncements\" Location=\"Resource(wss,noXinviewofY_LIST)\" /><ParameterBinding Name=\"NoAnnouncementsHowTo\" Location=\"Resource(wss,noXinviewofY_DEFAULT)\" /></ParameterBindings></View></Views><Forms><Form Type=\"DisplayForm\" Url=\"DispForm.aspx\" SetupPath=\"pages\\form.aspx\" WebPartZoneID=\"Main\" /><Form Type=\"EditForm\" Url=\"EditForm.aspx\" SetupPath=\"pages\\form.aspx\" WebPartZoneID=\"Main\" /><Form Type=\"NewForm\" Url=\"NewForm.aspx\" SetupPath=\"pages\\form.aspx\" WebPartZoneID=\"Main\" /></Forms></MetaData></List>"
  }
}
Request error:
{
  "status": 500,
  "statusText": "Internal Server Error",
  "headers": {
    "cache-control": "private, max-age=0",
    "transfer-encoding": "chunked",
    "content-type": "application/json;odata=nometadata;streaming=true;charset=utf-8",
    "expires": "Tue, 14 Dec 2021 15:53:53 GMT",
    "last-modified": "Wed, 29 Dec 2021 15:53:53 GMT",
    "vary": "Origin",
    "p3p": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"",
    "x-sharepointhealthscore": "1",
    "x-sp-serverstate": "ReadOnly=0",
    "dataserviceversion": "3.0",
    "spclientservicerequestduration": "205",
    "x-aspnet-version": "4.0.30319",
    "sprequestguid": "2a9111a0-b0f8-3000-90b9-ae1a7e4271fa",
    "request-id": "2a9111a0-b0f8-3000-90b9-ae1a7e4271fa",
    "ms-cv": "oBGRKviwADCQua4afkJx+g.0",
    "strict-transport-security": "max-age=31536000",
    "x-frame-options": "SAMEORIGIN",
    "content-security-policy": "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com *.dynamics.com;",
    "x-powered-by": "ASP.NET",
    "microsoftsharepointteamservices": "16.0.0.22001",
    "x-content-type-options": "nosniff",
    "x-ms-invokeapp": "1; RequireReadOnly",
    "x-cache": "CONFIG_NOCACHE",
    "x-msedge-ref": "Ref A: A1AAF8DC9199485AA1ED4C5DF026677F Ref B: LON21EDGE1318 Ref C: 2021-12-29T15:53:53Z",
    "date": "Wed, 29 Dec 2021 15:53:52 GMT",
    "connection": "close"
  },
  "error": {
    "odata.error": {
      "code": "-2130575237, Microsoft.SharePoint.SPException",
      "message": {
        "lang": "en-US",
        "value": "Invalid list template."
      }
    }
  }
}
Error: Invalid list template.

CLI for Microsoft 365 version

v4.2.0

nodejs version

v14.17.0

Operating system (environment)

Windows

Shell

bash

cli doctor

{ “os”: { “platform”: “linux”, “version”: “#1 SMP Tue Jun 23 12:58:10 UTC 2020”, “release”: “4.19.128-microsoft-standard” }, “cliVersion”: “4.2.0”, “nodeVersion”: “v14.17.0”, “cliAadAppId”: “31359c7f-bd7e-475c-86db-fdb8c937548e”, “cliAadAppTenant”: “common”, “authMode”: “DeviceCode”, “cliEnvironment”: “”, “roles”: [], “scopes”: [ “AllSites.FullControl”, “AppCatalog.ReadWrite.All”, “ChannelMember.ReadWrite.All”, “ChannelMessage.Send”, “ChannelSettings.ReadWrite.All”, “Directory.AccessAsUser.All”, “Directory.ReadWrite.All”, “Group.ReadWrite.All”, “IdentityProvider.ReadWrite.All”, “Mail.ReadWrite”, “Mail.Send”, “Reports.Read.All”, “Tasks.ReadWrite”, “Team.Create”, “TeamMember.ReadWrite.All”, “TeamsApp.ReadWrite.All”, “TeamsAppInstallation.ReadWriteForUser”, “TeamSettings.ReadWrite.All”, “TeamsTab.ReadWrite.All”, “TermStore.ReadWrite.All”, “User.Invite.All”, “User.ReadWrite.All”, “profile”, “openid”, “email”, “AllSites.FullControl”, “AppCatalog.ReadWrite.All”, “ChannelMember.ReadWrite.All”, “ChannelMessage.Send”, “ChannelSettings.ReadWrite.All”, “Directory.AccessAsUser.All”, “Directory.ReadWrite.All”, “Group.ReadWrite.All”, “IdentityProvider.ReadWrite.All”, “Mail.ReadWrite”, “Mail.Send”, “Reports.Read.All”, “Tasks.ReadWrite”, “Team.Create”, “TeamMember.ReadWrite.All”, “TeamsApp.ReadWrite.All”, “TeamsAppInstallation.ReadWriteForUser”, “TeamSettings.ReadWrite.All”, “TeamsTab.ReadWrite.All”, “TermStore.ReadWrite.All”, “User.Invite.All”, “User.ReadWrite.All” ] }

Additional Info

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24 (19 by maintainers)

Most upvoted comments

After doing some research, I’ve noticed that this is a common issue. I’ve also had a look at different PnP repositories, and none of these support creating a list by using the SchemaXML option.

I have found one example of a user which will ‘parse’ the XML from the SchemaXML and will set all the possible list options upon creation. The example can be found below: https://reshmeeauckloo.wordpress.com/2016/10/22/create-lists-libraries-from-schema-as-xml-using-csom/

Also when testing this using CSOM in a simple console application the same error is thrown, even while using the most simple SchemaXML that you can imagine. I have read examples of users for whom this works, but that was on very old environments (SP2010/SP2013), and while using SSOM code. Can’t imagine that it has ever worked unfortunately.

Any other thoughts?

I should be able to have a look at this

Will have a look upcoming days; this might be a bigger problem with our current implementation.

If this is the issue, then it’s coming from the underlying shell that requires a specific sequence for escaping quotes and it’s nothing that we could do about. One workaround for such cases is to store the payload in a file and pass the argument from a file using @. That way you don’t need to worry about escaping quotes.

If we can’t get it to work for any case, let’s update the docs and mark the option as deprecated, and to be removed in the next major version of the CLI.

I did indeed @waldekmastykarz. I’ve tried using the following Schema: <List Title='CustomList' BaseType='0'></List> Which is the most basic I suppose. I also tried adding the property Type to specify the list template, but that didn’t help either.