I trying to pass a DateTime object as a query string parameter to a webservice method built with ServiceStack.net.
The date is properly URL encoded when passed but I keep getting the following error:
"Message":"KeyValueDataContractDeserializer: Error converting to type: String was not recognized as a valid DateTime.
Any ideas of how to correct this?
Here is an example of the URL encoded DateTime I was passing: 2%2f24%2f2012+5%3a13%3a02+PM
If you have to pass datetimes as strings, try to pass them in an unambiguous format. I assume you’re tying to pass the 24th February 2012, 17:13:02 – something like the following would be unambiguous:
E.g. if you’re formatting the date in .NET, use “o” or “s”
This is nothing to do with URL encoding – it’s to do with passing data unambiguously – dates such as 01/02/2012 can be interpreted at least two ways – 1st February or 2nd January of this year, for two.