'Odata DateTime TimeZone issue on PUT method after migration from .net4.7 to .net6

We are trying to move our solution from .net4.7 to .net6. We are facing an issue with DateTime values while using OData 8.0.8 From the pictures below you can see that in both solutions values send are the same, but in the PUT method the date values received are different. In .net4.7 solution we are using:

config.SetTimeZoneInfo(TimeZoneInfo.Local);

And in the new solution the time zone is set like this:

services.AddControllers()
            .AddOData(opt =>
            {
                opt.EnableQueryFeatures().AddRouteComponents("odata/{language}", ODataModelBuilder.GetEdmModel()).TimeZone = TimeZoneInfo.Local;
            })

Is it OData bug or we are missing something?

Same request in .net4.7 and in .net6

Difference on backend visible in Watch



Solution 1:[1]

We did conclude that if you do not have [FromBody] attribute in front of your complex parameter in POST/PUT method, OData will not even consider it as Odata parameter. That means that Odata serializer/deserializer will not be runed at all. Also have it in the mind that OData works only with application/json content type.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jovica Madzevic