UPDATE: solved! Nothing to see here, please move on 🙂
I have an ApiController method that takes a System.Version parameter. The parameter is passed in the request body, as JSON. This is what gets sent:
{
“Major”: 0,
“Minor”: 7,
“Build”: 0,
“Revision”: 0,
“MajorRevision”: 0,
“MinorRevision”: 0
}
The routing works – my method is being called – but the parameter has an empty Version object (all values zero). Why?
Here’s the declaration of the controller method:
// POST api/service/details
[HttpPost]
[ActionName("Details")]
public ServiceDto Get(Version version)
{
}
To prevent anyone else from trying to answer this, the answer is that the System.Version class has no public setters on its members. Hence it cannot be de-serialized properly, and remains in its initial state. I had to use my own “Version” class that had publicly-settable members, and that worked fine.