{"record":{"id":"1c02d2fea8f2a97f","repo":"restsharp/RestSharp","slug":"couldn-t-parse-the-value-of-value-into-the-p","errorCode":null,"errorMessage":"Couldn't parse the value of '{value}' into the '{prop.Name}' property, because it isn't a type of '{prop.PropertyType}'.","messagePattern":"Couldn't parse the value of '(.+?)' into the '(.+?)' property, because it isn't a type of '(.+?)'\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/RestSharp.Serializers.Xml/XmlDeserializer.cs","lineNumber":185,"sourceCode":"                    continue;\n                }\n\n                type = type.GetGenericArguments()[0].GetTypeInfo();\n            }\n\n            var asType = type.AsType();\n\n            if (asType == typeof(bool)) {\n                var toConvert = value.ToString()!.ToLower(Culture);\n\n                prop.SetValue(x, XmlConvert.ToBoolean(toConvert), null);\n            }\n            else if (type.IsPrimitive) {\n                try {\n                    prop.SetValue(x, value.ChangeType(asType), null);\n                }\n                catch (FormatException ex) {\n                    throw new FormatException(\n                        $\"Couldn't parse the value of '{value}' into the '{prop.Name}'\" +\n                        $\" property, because it isn't a type of '{prop.PropertyType}'.\",\n                        ex.InnerException\n                    );\n                }\n            }\n            else if (type.IsEnum) {\n                var converted = type.AsType().FindEnumValue(value.ToString(), Culture);\n\n                prop.SetValue(x, converted, null);\n            }\n            else if (asType == typeof(Uri)) {\n                var uri = new Uri(value.ToString(), UriKind.RelativeOrAbsolute);\n\n                prop.SetValue(x, uri, null);\n            }\n            else if (asType == typeof(string)) {\n                prop.SetValue(x, value, null);","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/restsharp/RestSharp/blob/6a5082169257438cd085f822f050d93256a8e499/src/RestSharp.Serializers.Xml/XmlDeserializer.cs#L167-L203","documentation":"Thrown during XML deserialization when a primitive property value from the XML cannot be converted (via ChangeType) to the property's declared type, producing a FormatException. The inner FormatException's original message is replaced with this contextual one naming the value and the target property/type.","triggerScenarios":"The XML element/attribute text cannot be parsed as the property's primitive type, e.g. an element mapped to an int contains 'abc', or a value mapped to a numeric type holds a non-numeric string, raising FormatException inside ChangeType.","commonSituations":"Schema drift where the server sends strings in numeric fields; locale/number-format mismatches; empty string in a non-nullable numeric field; boolean fields receiving non-boolean text other than those XmlConvert.ToBoolean handles.","solutions":["Inspect the raw XML response content to see the offending value for the named property.","Change the property type to string or a nullable type so conversion does not fail, then parse manually.","Ensure the server returns values compatible with the property's declared primitive type."],"exampleFix":"// before\npublic int Count { get; set; }\n\n// after\npublic int? Count { get; set; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var result = client.GetAsync<T>(req); } catch (DeserializationException ex) when (ex.InnerException is FormatException) { /* log raw XML, relax property types, or parse manually */ }","preventionTips":["Make XML-mapped numeric properties nullable or string to tolerate schema drift.","Log raw XML content when deserialization fails to diagnose the offending value.","Validate server response shape during integration testing."],"tags":["xml","deserialization","type-conversion","primitive"],"backgroundTag":null,"analyzedSha":"6a5082169257438cd085f822f050d93256a8e499","analyzedAt":"2026-08-13T20:38:25.807Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}