I am writing a RESTful api using WCF Web Api Preview 6. I've just spent most of the day figuring out that it doesn't like "prettified" Json! I have a method which produces "human readable" Json, ie - it spreads the text over multiple lines to make it look nice ...
{
"fieldname": "value"
}
I eventually track down a strange problem I was having to the fact that I had pretty Json. If I changed it to this ...
{ "fieldname": "value" }
... it worked perfectly.
BUT, if I pasted the first example into the test client then it worked perfectly. Since it worked I dismissed that as being the cause very early on in my investigations. But, I came back around to it after having eliminated every other possibility.
The error I was getting was a bit misleading ...
System.InvalidOperationException: The service operation 'Post' expected a value assignable to type 'MyType' for input parameter 'resource' but received a value of type 'HttpRequestMessage`1'.
So, my question is. Does the test client do something to the body of the request to make it work with the built-in serializer?