我想爲OData協議V4(Microsoft.OData.Core)使用ODataLib生成Atom格式的有效載荷。我保證,Content-Type和Accept標頭是指應用程序/原子+ XML,然而CreateODataEntryWriter一個電話總是導致異常:OData V4的ODataLib是否支持請求中的Atom載荷?
Microsoft.OData.Core.ODataContentTypeException:支持的MIME類型 不能被發現匹配 請求的可接受的MIME類型。支持的類型 'application/json; odata.metadata = minimal; odata.streaming = true; IEEE754Compatible = false, application/json; odata.metadata = minimal; odata.streaming = true; IEEE754Compatible = true, application/json; odata.metadata = minimal; odata.streaming = true, application/json; odata.metadata = minimal; odata.streaming = false; IEEE754Compatible = false, application/json; odata.metadata = minimal; odata。 streaming = false; IEEE754Compatible = true, application/json; odata.metadata = minimal; odata.streaming = false, application/json; odata.metadata = minimal; IEEE754Compatible = false, application/json; odata.metadata = minimal ; IEEE754Compatible = true, application/json; odata.metadata = minimal, application/json; o data.metadata = full; odata.streaming = true; IEEE754Compatible = false, application/json; odata.metadata = full; odata.streaming = true; IEEE754Compatible = true, application/json; odata.metadata = full; odata。 streaming = true, application/json; odata.metadata = full; odata.streaming = false; IEEE754Compatible = false, application/json; odata.metadata = full; odata.streaming = false; IEEE754Compatib ...' 請勿匹配任何可接受的MIME類型'application/atom + xml'。
這裏的示例代碼導致異常:
var writerSettings = new ODataMessageWriterSettings();
writerSettings.SetContentType(ODataFormat.Atom);
var messageWriter = new ODataMessageWriter(request, writerSettings, model);
var entryWriter = messageWriter.CreateODataEntryWriter();
我檢查了庫代碼,發現ODataMessageWriterSettings有一個屬性EnableAtom但這個屬性被聲明爲內部的,它似乎沒有不從庫內部設置,所以它看起來總是假的。我知道Atom格式在OData V4中已經過時,是否支持輸入有效負載?
謝謝,這解釋了它。 – 2014-09-26 13:39:02