4

Closed

application/json should return json verbose when MaxDataServiceVersion is 2.0

description

We should return json verbose payload when old client requests for json. This is the same behavior as WCF DS.

Currently, we always returns json light payload and fails when MaxODataServiceVersion is lower than 3.0.

The fix is to make CanWriteType smarter about DataServiceVersion, or won't fix it as we are only V3.0 service.
Closed Oct 3, 2013 at 10:26 PM by danroth27
We don't support OData v2.0.

comments

HongmeiG wrote Feb 4, 2013 at 9:33 PM

The OData lib does not like the DataServiceVersion = 2.0 as it does not support the fullmetadata with 2.0.

Here is the exception message
  • $exception "A supported MIME type could not be found that matches the acceptable MIME types for the request. The supported type(s) 'application/atom+xml;type=feed, application/atom+xml, application/json;odata=verbose, application/json' do not match any of the acceptable MIME types 'application/json; odata=fullmetadata; charset=utf-8'." System.Exception {Microsoft.Data.OData.ODataContentTypeException}
Here is the stack
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObject(object graph, Microsoft.Data.OData.ODataMessageWriter messageWriter, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 61 + 0x11 bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync.AnonymousMethod__9() Line 425 + 0x2f bytes C#
System.Web.Http.OData.dll!System.Threading.Tasks.TaskHelpers.RunSynchronously(System.Action action, System.Threading.CancellationToken token) Line 208  C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(System.Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext) Line 339 + 0x33 bytes C#
System.Net.Http.Formatting.dll!System.Net.Http.ObjectContent.SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) Line 112 + 0x3a bytes C#
System.Net.Http.dll!System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream, System.Net.TransportContext context) Line 223 + 0xf bytes  C#
System.Net.Http.dll!System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream) Line 259 + 0x7 bytes   C#
System.Web.Http.SelfHost.dll!System.Web.Http.SelfHost.Channels.HttpMessageEncoderFactory.HttpMessageEncoder.WriteMessage(System.ServiceModel.Channels.Message message, System.IO.Stream stream) + 0x13b bytes   
System.Web.Http.SelfHost.dll!System.Web.Http.SelfHost.Channels.HttpMessageEncoderFactory.HttpMessageEncoder.WriteMessage(System.ServiceModel.Channels.Message message, int maxMessageSize, System.ServiceModel.Channels.BufferManager bufferManager, int messageOffset) + 0x266 bytes   

mdesousa wrote May 29, 2013 at 5:53 PM

We are seeing a similar issue, except that we just get a generic error message. This request was issued by Pebble Reports. The problem goes away if I issue the same request from Fiddler, without the MaxDataServiceVersion header.

Request:
GET https://odata.mysite.com/odata/resource HTTP/1.1
User-Agent: Microsoft ADO.NET Data Services
MaxDataServiceVersion: 2.0;NetFx
SL-User-Agent: OData Reporting
Accept: application/atom+xml,application/xml
Accept-Charset: UTF-8

Response:
<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code />
<m:message xml:lang="en-US">An error has occurred.</m:message>
</m:error>