Why OData Web API returns JSON only

只愿长相守 提交于 2019-12-24 08:53:18

问题


This is weird! I create OData Web API with ASP.NET MVC 5. Return IQueriable from the controller, nothing special.

But in some reason it constantly returns JSON when I need XML.

I send GET from Fiddler with Accept: application/xml - no reaction.

I try to force removing JsonFormater in the server code - no reaction again.

It always returns JSON. What do I miss?


回答1:


Try with - Accept: application/atom+xml.

AFAIK in OData V3 there are three protocals (ref) -

  1. Atom (application/atom+xml)
  2. JSON Verbose (application/json;odata=verbose)
  3. JSON Light (application/json;odata=light)


来源:https://stackoverflow.com/questions/21336879/why-odata-web-api-returns-json-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!