I'm working on developing an API using WebAPI2. One of its role is to produce a state required report, which needs to be in XML format.
I'm using a set of XSD's and auto-generated classes. I have an Enum property...
[System.Xml.Serialization.XmlTextAttribute()]
public CrewMemberRoles Value
When I make this enum nullable...
[System.Xml.Serialization.XmlTextAttribute()]
public CrewMemberRoles? Value
It forces WebAPI2 to return JSON instead of XML; Even though I have...
Content-Type: application/xml
Accept: application/xml
...In my HTTP headers.
I tried...
Configuration.Formatters.Remove(Configuration.Formatters.JsonFormatter);
...before the controller returns but WebAPI then returns a totally empty response.
Before I changed the enum to nullable, WebAPI returns the enum as the very first enum in the sequence, or the previous value used for this particular field in the previous call.
Any suggestions are appreciated.