AspNetCoreOData
AspNetCoreOData copied to clipboard
Use DateTime in ISO format in request and response
Short summary (3-5 sentences) describing the issue.
We want to use the ISO date-time format yyyy-MM-dd'T'HH:mm:ssZ for the Odata API request and response.
Which assemblies and versions are known to be affected e.g. OData WebApi lib 6.1.0
Microsoft.AspNetCore.OData(8.0.2) linq2db.EntityFrameworkCore(5.5.0)
What is actually happening.
{ "id": 11123, "customer_id": 3, "customer_name": "Test By Vishal Thoriya", "receipted_at": "2018-11-15T12:00:00+05:30", "payment_method_type": "EFT", "reference": "erytruy", "amount": 113.0000, "payment_processing_type": "manual", "transaction_id": "erytruy", "status": "Completed", "customer_type": "buyer" },
Currently, it is giving results in above datetime format "2018-11-15T12:00:00+05:30", but we want in "2021-04-13T14:15:22Z"
@Reena-Patel Can you use the TimeZoneInfo configuration on ODataOptions?
@Reena-Patel Was you issue resolved?
@KenitoInc No
Did you try @xuzhg's suggestion?
Is there any chance to fix this issue?
It would be nice if the AddODataNewtonsoftJson method is allow to pass a parameter of JsonSerializerSettings type
Is there any chance to fix this issue?
There is nothing to "fix" though, unless you mean the suggestion above doesn't work for you. Date formatting is already configurable.
It would be nice if the
AddODataNewtonsoftJsonmethod is allow to pass a parameter ofJsonSerializerSettingstype
I'm not sure that method does what you think it does... OData has it's own Json serialization logic that it uses for actual OData-formatted payloads. This method just adds a few converters to "tell" Newtonsoft how to serialize a few of its specific types so they can work outside of OData contexts, so passing JsonSerializerSettings on that method would make very little sense I think.