Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OData version 2 and 3 differences

Tags:

rest

odata

OData protocol documentation (http://www.odata.org/documentation) describes two versions - 2 and 3.

What are the core differences between two versions?

Are both versions are supported by existing client libraries or version 2 is considered to be "legacy"?

To rephrase - are version 2 clients compatible with version 3?

like image 649
Dmitry Buzdin Avatar asked Feb 06 '13 10:02

Dmitry Buzdin


People also ask

What is the difference between OData V2 and OData V4?

According to the OData 2 specification, payload had to be retrieved in both XML and JSON formats. In OData 4 however, XML is optional. So, Hybrid Data Pipeline today supports both XML and JSON in OData 2 and only JSON in OData 4. However, the metadata can still be retrieved in the XML format in OData 4.

What is OData V2?

The OData model is a server-side model, meaning that the data set is only available on the server and the client only knows the currently visible (requested) data. Operations, such as sorting and filtering, are done on the server. The client sends a request to the server and shows the returned data.

What is OData V3?

The Open Data Protocol (OData) is a data access protocol for the web. OData provides a uniform way to structure data, query the data, and manipulate the data set through CRUD operations (create, read, update, and delete). OData supports both AtomPub (XML) and JSON formats.

What are OData types?

The odata. type annotation specifies the type of a JSON object or name/value pair. Its value is a URI that identifies the type of the property or object. For built-in primitive types the value is the unqualified name of the primitive type, specified as a URI fragment.


2 Answers

There are lots of differences between the two versions. For example, OData v3 adds support for actions, functions, collection values, navigation properties on derived types, and stream properties. It also introduces a completely new serialization format for JSON ("application/json" means completely different things in the two versions).

When an OData client makes a request to a server, it can (and should) specify the maximum protocol version it can understand via the MaxDataServiceVersion HTTP header. A client written to only understand v2 of the protocol won't be able to understand a v3 payload.

I don't think I'd call v2 "legacy" or unsupported, but individual servers can choose whether or not to support requests that can only understand up to v2 (or v1). I think many existing clients out there support both v2 and v3. I know the WCF Data Services clients (desktop, windows phone, windows store, and silverlight) do support both.

like image 130
Jen S Avatar answered Sep 21 '22 04:09

Jen S


In addition to a previous answer be aware that some client tools may still support only OData v2 protocol, so in case you need v3 specific features, you should make sure your client code is not limited by something like auto-generated proxy classes that are not capable of handling array types.

Here's an example when server exposes v3 features, but it's not possible to use them because Visual Studio WCF Data Service client proxy generator only supports v2:

http://bloggingabout.net/blogs/vagif/archive/2012/12/16/using-odata-protocol-v3-with-mongodata-odata-provider.aspx

like image 27
Vagif Abilov Avatar answered Sep 20 '22 04:09

Vagif Abilov