Search code examples
odataasp.net-web-apiasp.net-web-api2

Web API OData format as XML


I am testing a Web API project using OData and EF to return results form a SQL Server view. It took a while but I finally got it working. What I'd like to do next is use a different formatter to return the results.

According to this link I should have options for atom, json, and xml using the $format parm. But this parm appears to be ignored. Digging some more I found articles similar to this one that say you have to add commands to allow the $format parm to work but I have no reference to "Configuration.Formatters.XmlFormatter.AddQueryStringMapping" which I've found in several other articles. I have seen references to testing with Fiddler and the updating to return JSON for example but I want to use $format so I can also pull different formats in SSIS.

The closest thing I find is this post but there is no solution for XML besides Fiddler and the JSON $format commands do not work for me. I assume that maybe things changed in the past 4 months.

Is there anyway to get $format to work with XML?


Solution

  • I am going to say this is a problem with the VB.Net version of the code. It seems to work fine if you switch to C#.