Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kdambekalns
Last active October 9, 2015 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdambekalns/43dde8c315bdbec1862b to your computer and use it in GitHub Desktop.
Save kdambekalns/43dde8c315bdbec1862b to your computer and use it in GitHub Desktop.
Open questions on OData v4

This document collects some odd bits and pieces on OData v4.

Content negotiation

The $metadata document

The OData specification says:

If a request for metadata does not specify a format preference (via Accept header or $format) then the XML representation MUST be returned.

(see http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398289)

Now, what if the client actually requests a format preference, and it does not include application/xml? In theory, the server should return an error, stating the content is not acceptable (406). But the question is, how do actual OData clients in the wild do this? Do they request /$metadata with the correct Accept header, or would they break of the server actually behaved correctly?

Requesting the Number of Items in a Collection

Content negotiation using the Accept request header or the $format system query option is not allowed with the path segment /$count.

(see http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398314)

So, if the client asks for the count of items, content negotiation is not allowed, the result must be text/plain. For correct HTTP behavior the client must include text/plain with the accepted formats, otherwise the server should return a 406 status. Now, the only specified formats for OData are a JSON and an XML representation, so I'd expect clients to request those… but do they also allow text/plain in "real life"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment