QuestionI read a table of 5,000 rows from
/odata/Cities and I only get 1000 rows back. If I ask for
$top=5000 I get a 400. How do I read everything?
AnswerEvery response carries at most
odataMaxTop rows (default 1000), even when you send no
$top; a larger
$top is rejected with 400. You read the rest by paging, not by raising the limit in the request.
The two ways:
- Ask for
$count=true and follow the link. The response becomes { "value": [...], "@odata.count": N }. When the page was cut by the limit (you sent no $top) the wrapper also carries @odata.nextLink: the same request with the $skip of the next page. Follow it until it disappears. - Page by hand with
$top and $skip. Use $top up to the limit and increase $skip by that amount each time. With an explicit $top there is no nextLink; you stop when you get fewer rows than you asked for, or when you reach @odata.count.
The trap is the plain array: without
$count=true the endpoint answers a bare JSON array with no link, so an export that stops at exactly the row limit is truncated, not complete. Always add
$count=true in scripts, so you can compare what you read with the total.
Paging is stable: the server appends the primary key to your
$orderby (or orders by the key alone), so rows are not lost or repeated between pages. The total in
@odata.count is computed after
$filter and before
$skip/
$top.
curl -H "Authorization: Bearer wuic_pat_..." \
"https://<host>/odata/Cities?\$count=true&\$orderby=cityName"
# -> { "@odata.count": 5000, "value": [ ...1000 rows... ],
# "@odata.nextLink": "https://<host>/odata/Cities?...&$skip=1000" }
If you really need larger pages, raise
odataMaxTop in the application settings, keeping in mind that each response is materialized in memory.
Documentation: OData