Issue with Datetime format when passing as json request in custom webservices
Getting dateformat error during deserialization when calling a custom web service with the following JSON request:
{
"ResultDate": "\"2000-01-01T00:00:00.000\""
}
The error message states:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:entity... "DateTime content '"2000-01-01T00:00:00.000"' does not start with '/Date(' and end with ')/' as required for JSON.' Please see InnerException for more details. See server logs for more details. The exception stack trace is: ...
Is there any way to pass a date in the "\"2000-01-01T00:00:00.000\"" format instead of using /Date(1511448000000)/?
Like
Hello,
According to the given information, this article may be helpful:
Also, you can write a DateTime to Unix timestamp converter and then extract the value:
public static DateTime UnixTimeStampToDateTime( double unixTimeStamp ) { DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dateTime = dateTime.AddSeconds( unixTimeStamp ).ToLocalTime(); return dateTime; }
Best regards,
Anhelina!