REST API Date format

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”
}

Why are you putting +11:00 at the end of your time?

I tried without +11:00 like “UD04_Date20”: “2021-10-28T01:01:00” and getting below error.

{
“error”: {
“code”: “”,
“message”: “The request is invalid.”,
“innererror”: {
“message”: “patch : Cannot convert the literal ‘2021-10-28T01:01:00’ to the expected type ‘Edm.DateTimeOffset’.\r\n”,
“type”: “”,
“stacktrace”: “”
}
}
}

I can see the saved data is in the following format: 2018-06-05 12:09:59.957
Could you try pushing your data in this shape ?

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?

It didn’t work

UBaq is working in the UI. Date format in the UI is dd/mm/yyyy.

you might have to put a trace on the UBAQ. What it shows in the UI isn’t necessarily what it passes in.

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.

Try this.

“UD04_Date20”: 2021-10-28T00:00:000Z