10

My OData query is returning a limited number of results. It seems to stop at 25. Why is this, and how can I make it return the full resultset?

9

As you found out, the maximum number of results is 25 by default, and that is controlled via the cd_webservice_conf.xml file.

You can turn the limit OFF completely, by setting it to 0

<DefaultTop>0</DefaultTop>

But I strongly advise against this, as you don't know who the next developer is on your server, and whether he'll understand that there is a performance penalty to retrieving 200K items from the service.

A much better approach, in my view, is to use the $top query option for the particular queries where you need more than %default% results. If you really want to get everything in your query, then use $top=0.

6

The max number of results to return is configurable in cd_webservice_conf.xml. It contains the element DefaultTop which controls this:

<!--
OData specific settings.

The default top value that will be used if the client doesn't specify one.
The fixed publication id to use in the friendly URL, this allows only one
publication to be queried through the friendly URL filter.
-->
<OData>
    <DefaultTop>25</DefaultTop>
    <FixedPublicationId>1</FixedPublicationId>
</OData>

So if you don't want a limit, then simply set DefaultTop to some ridiculously high number. But be warned, the response may take a really long time to download if you have a large number of items and ask to return all them.

  • 3
    Better yet, use $top on your query to specify the maximum number of results you want – Nuno Linhares Jun 9 '13 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.