Manage invalid characters
There are a set of characters that cannot be saved in string or memo columns. When an application saves data containing these characters to Dataverse, the following error will occur:
Name: InvalidCharactersInField
Hexadecimal error code : 80040278
Error Number: -2147220872
Description: The field '{0}' contains one or more invalid characters.
Dataverse uses the System.Xml.XmlConvert.VerifyXmlChars(String) Method for every string value passed to these columns. This error is thrown on the first invalid character encountered.
You may encounter these characters in email content that includes replies or when text is copied from another source which may have characters to control presentation.
To prevent this error you can:
HTML encode the content before saving.
Remove the individual invalid characters, use the System.Xml.XmlConvert.IsXmlChar(Char) Method as shown in the following example:
static string RemoveInvalidXmlChars(string text) { var validXmlChars = text.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray(); return new string(validXmlChars); }