I am having an issue with a date conversion error when updating the date calling the updatable BAQ service through Postman. Any help is much appreciated.
“UD04_Date20”: “2021-10-28T00:00:00+11:00”
{
“HttpStatus”: 500,
“ReasonPhrase”: “REST API Exception”,
“ErrorMessage”: “Unable to cast object of type ‘System.DateTimeOffset’ to type ‘System.IConvertible’.Couldn’t store <28/10/2021 12:00:00 AM +11:00> in UD04_Date20 Column. Expected type is DateTime.”,
“ErrorType”: “System.ArgumentException”,
“CorrelationId”: “6a50fc9e-c242-4e3a-879f-cdbe7846170e”
}
Is your Ubaq working in the UI? When you send in something via JSON the date with be a string. That means that you should be sending in the same exact string as what you type into your UBAQ. Is that what you are doing?
UD date columns are just SQL date format. SQL is typically happy converting standard variants of YYYYMMDD. select cast('20210101' as date) parses out to January 1st, 2021. Same story for ‘2021-01-01’, and ‘2021/01/01’.
Passing in datetime equivalent strings also works for cast() in SQL. select cast('20200101 01:01:01.001' as date) also parses to January 1st, 2021. It is generally better to trim date strings back to just the date portion though.
That’s not acknowledging what kind of shenanigans the REST API intermediary gets up to with the values you give it. I haven’t caught it tinkering with the values I give it, maybe a token sanity check here and there, but for the most part it acts like a naive conveyor belt.