Key cannot be null for AddFieldAsXml

I was using Office PnP library to create SPOField. I got “Key cannot be null” error. I checked all the options for the XML file. Finally this is the correct XML text worked for the call. Please note there should be default XML Namespace.

You will get same error if you are using the PowerShell Solutions from Office PnP

<?xml version=”1.0″ encoding=”utf-8″?>
<Field xmlns=”http://schemas.microsoft.com/sharepoint/&#8221;
ID=”{8478039d-fbd5-421d-bd6c-87a07d7ce499}”
Name=”ContosoStatus”
DisplayName=”Contoso Status”
Type=”Choice”
Required=”FALSE”
Group=”Contoso Site Columns”>
<Default>Draft</Default>
<CHOICES>
<CHOICE>Draft</CHOICE>
<CHOICE>Review</CHOICE>
<CHOICE>Final</CHOICE>
</CHOICES>
</Field>

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s