You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Empty Collection Recommendations based on #217
Service providers are unclear if they should return 404s when collection searches have no results. Per the advice in the issue 217 thread the recommendation is to NOT return a 404 in these cases and instead maintain consistency in their response and signifying no results as _value_ containing an empty array.
"We would always say that should return a 200 with an empty collection. The call succeeded, the collection exists. There's just nothing in it.
Given we always follow the convention of having the array itself be a 'value' property on a top-level object representing the collection itself, there's also the ability to return collection metadata that is valid regardless of whether there is anything in the collection, e.g. MaxItems." -- Gareth Jones
* TOC formatting
moving to a new section. 9.10.
* typo and lower case property name
@@ -1006,6 +1007,27 @@ When these operations are performed together, the evaluation order MUST be:
1006
1007
2.**Sorting**. The potentially filtered list is sorted according to the sort criteria.
1007
1008
3.**Pagination**. The materialized paginated view is presented over the filtered, sorted list. This applies to both server-driven pagination and client-driven pagination.
1008
1009
1010
+
### 9.10. Empty Results
1011
+
When a filter is performed on a collection and the result set is empty you MUST respond with a valid response body and a 200 response code.
1012
+
In this example the filters supplied by the client resulted in a empty result set.
1013
+
The response body is returned as normal and the _value_ attribute is set to a empty collection.
1014
+
A client MAY be expecting metadata attributes like _maxItems_ based on the format of your responses to similar calls which produced results.
1015
+
You SHOULD maintain consistency in your API whenever possible.
1016
+
1017
+
```http
1018
+
GET https://api.contoso.com/v1.0/products?$filter=(name eq 'Milk' or name eq 'Eggs') and price lt 2.55
0 commit comments