Web API 2 OData = $ format doesn't work

Thanks in advanced for any help guys.

I have an OData Web API project and everything works fine. Now I am trying to return xml instead of JSON using the $ format parameter as opposed to specifying the request header and it does not work. I've tried these approaches:

http://localhost:3845/api/Customer?$format=application/xml
http://localhost:3845/api/Customer?$format=xml
http://localhost:3845/api/Customer?$format=application/xml;odata.metadata=full

      

All without success. This article says it's possible: http://blogs.msdn.com/b/webdev/archive/2014/03/13/getting-started-with-asp-net-web-api-2-2-for -odata-v4-0.aspx

I have updated all of my NuGet packages, but it seems like the request is always ignored and instead I get JSON every time.

Thanks again for any ideas. Regards...

+3


source to share


1 answer


Because the ATOM (XML) format is a technical committee specification and not an OASIS standard for the OData V4 protocol, the ATOM format is disabled in ODataLib from version 6.3. 0 .

The correct way to ask the OData V4 service to respond in XML is like this:



GET http://localhost:3845/api/Customer?$format=application/atom+xml

      

or set the title Accept

to application/atom+xml

. But for the reason mentioned above, it does not work for Web API OData V4.

+6


source







All Articles