Web Api with OData v4 throwing exception on $select

后端 未结 2 749
猫巷女王i
猫巷女王i 2021-01-06 09:45

I\'m using the latest version of WebApi and OData and everything is set up to work right. The only problem is when I try to use $select .

It throws the error bellow

2条回答
  •  天命终不由人
    2021-01-06 10:46

    This is a known limitation of the XmlMediaTypeFormatter class from the System.Net.Formatting Nuget package. The implementation of the JSON formatter does support the $select and $expand commands but these are not available when content negotiation determines that XML should be returned.

    You should look into implementing OData endpoints (as opposed to WebAPI endpoints) should you need to return XML formatted responses. More information on how this can be done can be found here:

    http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options

提交回复
热议问题