NJsonApiCore icon indicating copy to clipboard operation
NJsonApiCore copied to clipboard

DateTimeOffset is not supported on POST

Open brainwipe opened this issue 9 years ago • 1 comments

When you POST a document that uses the C# type DateTimeOffset, you will receive a 500 error, internally this is an InvalidCastException.

GET works fine as this is a simpler serialisation.

Investigation

I believe it is because the attribute holding the time is being cast into a DateTime type rather than DateTimeOffset.

brainwipe avatar Aug 28 '16 10:08 brainwipe

I think this is related to the type conversions on POST/PATCH. The Delta object key/value pairs have wrong typed values for given properties. For instance, long (for an int in the model) or a double (for a Decimal in the model). It looks like de-serialization on POST/PATCH is either not using the right type information or entirely ignores it. This is quite an issue even for simple properties. Even the sample project stops working when you add an int property to Article model and try to POST or PATCH.

cnolewajka avatar Dec 22 '16 13:12 cnolewajka