I use Fiddler to test my WCF Rest. I always get
HTTP/1.1 400 Bad Request
with this post value:
{
"session":{
"Session":"088a688d-ea69-4264-9266-381e9e540d00",
"LoginID":"testid",
"Serial":"testserial"
},
"sub":[
{
"Type":0,
"StartDate":"\/Date(1319731200000+0800)\/",
"EndDate":"\/Date(1319731200000+0800)\/",
"Duration":"12:12:12"
}
]
}
I get the error in 'Duration' value. I've been searching on net but no luck at all.
I hope I'll find the answer here. Thanks a lot!
The simple approach is to parse the timespan as a string and converting to a TimeSpan using its static 'parse' routine.
With JSON and WCF you are relying on the JSON Serialiser to convert objects back and forth, unfortunately once you start 'moving' away from native object types, i.e. strings, numerics, and into specific object, it tends to choke unless you use the exact format.
Personally, I've had no experience of passing Timespan's through the DataContractJsonSerializer what format is required, however this post will highlight the exact format along with whether it is possible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With