I have access to a OData service. Now I need find the OData version of the service. There are version attributes in $metadata. But I don't know which one to pickup.
Do I need to take it from <edmx:Edmx Version="1.0">
or DataServiceVersion
or from HTTP Header
For example,
http://services.odata.org/v4/%28S%28cy2mvwlr34teasunjfqlhlyg%29%29/TripPinServiceRW/$metadata returns Version as 4.0 but does not contain DataServiceVersion in the response. But it has OData Version HTTP header
http://services.odata.org/OData/OData.svc/$metadata returns Version as 1.0 and DataServiceVersion as 3.0. This does not contain OData Version HTTP header. But it has DataServiceVersion HTTP header
http://services.odata.org/V3/Northwind/Northwind.svc/$metadata returns Version as 1.0 and DataServiceVersion as 1.0. This does not contain OData Version HTTP header. But it has DataServiceVersion HTTP header
Please let me know how can I find the OData version using service metadata? Or is there any other way to find it?
According to OASIS standard, for each example:
Version
on the Edmx elementFor examples 2 and 3, you'll want to read this note about versioning which states:
You'lll notice things are kind of the wild wild west in terms of OData implementations (a lot of MAY's and SHOULD's. In terms of how the examples above fit this specification:
Version
must be1.0
, but that theDataServiceVersion
must be the version of OData protocol required to consume the service, and be one of['1.0','2.0','3.0']
, per spec.DataServiceVersion
of1.0
,2.0
or3.0
and still receive a response that fits the standard for the given version.So, depending on what service you're connecting to, you'll want to check differently. Maybe a flow like:
<edmx:Edmx />
version is4.0
(you know OData v4)<edmx:DataServices />
has aMaxDataServiceVersion
property (you now have highest available OData version)<edmx:DataServices />
has aMinDataServiceVersion
property (you now have minimum supported OData version)<edmx:DataServices />
has aDataServiceVersion
property (you now have minimum supported OData version)