OData / ODataSamples

Samples: For ODataLib, OData Web API, RESTier, etc.
http://odata.github.io/
Other
293 stars 222 forks source link

Is `https://services.odata.org/V2/(S(readwrite))/OData/OData.svc` V1 or V2? #119

Open boghyon opened 4 years ago

boghyon commented 4 years ago

The Reference Services page lists several OData V2 sample services. The description of the 2nd service says the following:

A simple OData v2 service optimized for quick browser demos.

https://www.odata.org/odata-services/#2

Also the DataServiceVersion in $metadata/OData/OData.svc/$metadata) is 2.0 which suggests that the service is OData V2.

However: the format of entity collections conforms more OData V1 rather than V2. See, for example, https://services.odata.org/V2/(S(readwrite))/OData/OData.svc/Products?$format=json:

{
 "d" : [ 
   { ... }, 
   { ... }, 
   { ... }, 
 ]
}

According to the spec:

6. Representing Collections of Entries

Collections represent a set of Entries. In OData v1, Collections are represented as an array of objects, with one object for each Entry within the Collection. For example, a collection of Entries would be represented as shown below. The format of each object in the array is described in the Representing Entries section. In OData v2, Collections are still represented as arrays, however to enable representing Collection-level metadata, the array of objects representing the set of Entries is included as the value of a "results" name/value pair.

OData V1: { 
  "d" : [ 
    { ... }, 
    { ... }, 
    { ... }, 
  ] 
} 
OData V2: { 
  "d" : { 
    "results":  [ 
      { ... }, 
      { ... }, 
      { ... }
    ] 
  }
}

So the question is: is the above mentioned service OData V1 or V2?

boghyon commented 4 years ago

With $inlinecount=allpages/OData/OData.svc/Products?$format=json&$inlinecount=allpages), I can see the "results" property, which suggests that the service is supposed to be V2. However, requesting a collection without such queries still results in { "d": [...] } which is a V1 format. Such inconsistency leads to issues on the client side. See for example stackoverflow.com/q/43661554.

boghyon commented 2 years ago

@KanishManuja-MS @mikepizzo Please see also the related issue https://github.com/OData/ODataSamples/issues/154