OData-Version
The OData-Version request and response header states which version of the Open Data Protocol produced the body of an HTTP message. The header leads a small family defined in the OASIS OData protocol specification: OData-MaxVersion caps the response version a client accepts, OData-EntityId names the entity a bodiless create or upsert touched, and OData-Isolation asks for a snapshot read. All four are registered as permanent fields with IANA, with the OASIS specification as the defining document.
Usage
A client sends OData-Version to say which protocol version generated the request body, and a service sends the header on every response to say which version generated the response body. The client side is a recommendation, the service side is a requirement. The two directions are independent: a request written as 4.0 and a response written as 4.01 are a valid pair when the negotiation below allows the newer version.
When a request carries the header, the service interprets the body under the rules of the named version or rejects the request with a 4xx status. When the request omits the header, the service assumes the lower of the OData-MaxVersion value and the highest version the service understands.
The specification defines two version values, 4.0 and
4.01, and the header grammar allows 4.0 followed by one
digit from 1 to 9, so 4.0 and 4.01 are the only values a
compliant service emits. Versions compare as decimals.
A service lists the versions it supports through the
Core.ODataVersions annotation in its metadata document.
Inside a $batch request, each individual part carries its
own OData-Version when needed, and parts without one
inherit the version of the surrounding batch.
Version negotiation with OData-MaxVersion
A client sends OData-MaxVersion to state the highest
protocol version the client parses, and the service answers with
the greatest version it supports at or below the cap. A client
built for 4.0 sends OData-MaxVersion: 4.0 and receives a 4.0
response even from a 4.01 service, which keeps the client
working after the service upgrades.
Without the header, a 4.01 service is expected to keep answering with the same version over time, treating the request as if it named the highest version the service supported when the service was first published. The 4.0 text reads the missing header as the highest version the service supports at all, so sending the header is the only portable way to pin the response shape.
The two versions differ in naming. OData 4.0 prefixed its
preferences and format parameters with odata., giving
odata.maxpagesize and odata.metadata=minimal, and named
the isolation header OData-Isolation. OData 4.01 dropped the
prefix, giving maxpagesize and metadata=minimal, and
renamed the header to Isolation. A 4.01 service supports the
old names for 4.0 clients, a client talking to an unknown
service sends the old names for compatibility, and when both
spellings appear in one request the 4.01 spelling wins. The
JSON format ties the prefix to the version header: a payload
labelled OData-Version: 4.0 carries the odata. prefix, and
a payload labelled 4.01 leaves the prefix out.
OData-EntityId
A response to a create or upsert that returns 204 No Content carries OData-EntityId with the entity-id of the entity the request created or updated. The value is an IRI, and the header exists because a bodiless response otherwise leaves the client without the identity of the record it wrote. A create that returns a body answers with 201 Created, a Location header pointing at the edit URL and the representation, and skips OData-EntityId.
The bodiless path appears whenever a service applies
return=minimal from the Prefer header, and in
services such as Microsoft Dataverse where 204 is the default
for POST and PATCH writes. The header stays
off the outer response of a $batch and appears on the
individual responses inside the batch instead. The ABNF spells
the field OData-EntityID while the prose writes
OData-EntityId. Field names are case-insensitive, so both
spellings denote the same header.
OData-Isolation and Isolation
The OData-Isolation request header, renamed Isolation in
OData 4.01, asks the service to evaluate the request against a
snapshot of committed data taken at the start of the request.
The only defined value is snapshot. Every page of a paged
result and every part of a batch then reflect one point in
time, with only the request's own modifications visible on top.
A service without snapshot support refuses the request and
answers 412 Precondition Failed instead of processing the
request without isolation. The next links in a snapshot
response stay inside the snapshot, so the client follows them
without repeating the header, while navigation, read and edit
links return current data. A next link into a snapshot the
service has released answers 410 Gone or 404 Not Found.
Services advertise support with the
Capabilities.IsolationSupported annotation.
In the IANA registry OData-Isolation is a permanent field and
Isolation is provisional. A 4.01 service accepts both names
and prefers the Isolation value when a request carries both.
Standard headers in OData requests
OData leans on the ordinary HTTP headers for content negotiation, preferences and concurrency, and adds rules on top of each.
Prefer and Preference-Applied
The Prefer header carries the OData preferences, and
a service ignores any preference it does not know. The
odata.maxpagesize preference caps every collection in the
response, including nested expanded collections, at the given
positive integer, and a service applying server-driven paging
echoes the applied size in
Preference-Applied, where the number is
allowed to differ from the request. The return=minimal and
return=representation preferences apply to POST,
PUT, PATCH and action requests, have no
effect on GET or DELETE, and earn a 4xx when
placed on the outer batch request. The
odata.include-annotations preference lists the annotation
terms the client wants, as a quoted comma-separated list with
* as a wildcard. A service honoring a preference also adds
Vary with the Prefer field name where the response
depends on the preference.
Content-Type and Accept
Every non-empty body carries Content-Type, and
the JSON format defines the parameters metadata, streaming,
IEEE754Compatible and ExponentialDecimals, written with the
odata. prefix under version 4.0. The metadata parameter
takes minimal, full or none and sets how much control
information the payload carries. Custom format parameters never
start with odata. The Accept header chooses the
response format. A service rejects format parameters it does
not know, answers 406 Not Acceptable when no supported
format fits, and adds no parameters the client did not ask
for. A $format query option overrides the header.
If-Match and ETag
Services that require optimistic concurrency send ETag
on every representation and expect the value, or *, back in
If-Match on PUT, PATCH,
DELETE and bound actions. A modification request
without the required validator fails with 428 Precondition
Required, and a stale validator fails with 412 Precondition
Failed, with no observable change in either case. OData prefers
weak ETags derived from entity state rather than from the
serialized bytes, and compares them with the weak comparison
function. If-Match: * on an upsert turns the request into an
update-only operation, and a missing entity counts as a
non-match. The header belongs on the individual requests inside
a batch, never on the batch itself.
Error responses
A request whose OData-Version the service cannot interpret
fails with a 4xx status, and the specification leaves the exact
code to the service. Any 4xx leaves the service state unchanged.
The error body is a JSON object with a required code and
message, optional target, details and innererror
members, and the response carries
Content-Language for the language of the
message. Specific conditions have fixed codes: 412 for an
unsupported snapshot isolation or a stale If-Match, 428
for a missing If-Match where one is required, 406 for an
unsupported format, and 400 Bad Request for malformed query
options such as a $count value other than true or false.
Services keep OData-Version on error responses too:
Dataverse and SAP both document OData-Version: 4.0 on every
error.
Example
A client creates an entity on a Dataverse-style service. The request names both the version of the body and the highest version the client accepts, and asks for JSON. The service applies its default of returning no body, so the identity of the new record arrives in OData-EntityId.
POST /api/data/v9.2/accounts HTTP/1.1
Host: api.example.re
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json
Content-Length: 25
{"name":"Sample Account"}
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: https://api.example.re/api/data/v9.2/accounts(00aa00aa-bb11-cc22-dd33-44ee44ee44ee)
A paging request asks for two items per page. The response
confirms the applied page size, labels the body with the 4.0
metadata parameter, and the body carries an @odata.nextLink
for the following page.
GET /api/data/v9.2/contacts?$select=fullname HTTP/1.1
Host: api.example.re
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Prefer: odata.maxpagesize=2
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.maxpagesize=2
A client asks for a snapshot read from a service without snapshot support. The service refuses the request outright, as the specification requires, and returns an OData error body.
GET /api/data/v9.2/accounts HTTP/1.1
Host: api.example.re
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
OData-Isolation: snapshot
HTTP/1.1 412 Precondition Failed
Content-Type: application/json; odata.metadata=minimal
Content-Language: en
OData-Version: 4.0
Content-Length: 82
{"error":{"code":"NotSupported","message":"Snapshot isolation is not supported."}}
Where developers meet the headers
Microsoft Graph exposes its resources as an OData 4.0 service.
Collection endpoints page through @odata.nextLink, and the
delta query endpoints document Prefer: odata.maxpagesize as
the way to cap the number of items per response.
The Dataverse Web API behind Dynamics 365 asks for
Accept: application/json, OData-MaxVersion: 4.0 and
OData-Version: 4.0 on every request, so the version in play
stays explicit when the service gains newer capabilities. The
API honors odata.include-annotations, odata.maxpagesize,
odata.track-changes, respond-async and
return=representation, and every response, including errors,
carries OData-Version: 4.0 with a JSON body labelled
odata.metadata=minimal.
SAP ships OData V4 through SAP Gateway Foundation on the ABAP
platform and through its cloud products. The SAP Sales Cloud
Version 2 solution guide requires OData-Version: 4.0,
OData-MaxVersion: 4.0, JSON Content-Type and Accept
headers on every request and response, controls the metadata
level through Accept, and requires OData-Version: 4.0 on
every error response.
Salesforce Connect consumes external OData services through
adapters for OData 2.0, 4.0 and 4.01. The adapters page with
$top and $skip by default, and an external data source
switched to server-driven paging lets the OData producer set
page sizes and batch boundaries through its own next links.
History
Microsoft's OData versions 1.0 to 3.0, published as the
MS-ODATA open specification, carried the version in
DataServiceVersion and the client ceiling in
MaxDataServiceVersion, each allowing a trailing user-agent
string after the number. OASIS approved OData 4.0 as an OASIS
Standard on 24 February 2014, renamed the pair to
OData-Version and OData-MaxVersion, and added
OData-EntityId and OData-Isolation. ISO/IEC adopted the
4.0 protocol as ISO/IEC 20802-1:2016. OData 4.01 became an
OASIS Standard on 23 April 2020, renamed OData-Isolation to
Isolation, dropped the odata. prefix from preferences and
format parameters, and kept the old names as compatibility
aliases. IANA registers OData-Version, OData-MaxVersion,
OData-EntityId and OData-Isolation as permanent fields and
Isolation as provisional, all pointing at the 4.01 protocol
document.
See also
- OData Version 4.01 Part 1: Protocol
- OData Version 4.0 Part 1: Protocol (Errata 03)
- OData JSON Format Version 4.01
- OData ABNF Construction Rules
- IANA HTTP Field Name Registry
- MS-ODATA: MaxDataServiceVersion
- Microsoft Graph: Get incremental changes to messages
- Dataverse Web API: Compose HTTP requests and handle errors
- Dataverse Web API: Perform conditional operations
- SAP Sales Cloud Version 2: OData V4
- SAP Gateway Foundation for OData V4 Developer Guide
- Salesforce Connect: Client-Driven and Server-Driven Paging
- Prefer
- Preference-Applied
- Content-Type
- Accept
- If-Match
- ETag
- Location
- Conditional requests
- 204
- 412
- 428
- HTTP headers