2
votes

I have developed an API using Microsoft Graph API. I am encountering below issue.

URL that I am calling :

/v1.0/sites/root/lists/cb32cc85-5351-423d-b2ec-bb418c1d9c64/items?
$filter=fields/Created gt '2018-1-1T00:00:00'
&expand=fields
&$orderby=createdDateTime
&$top=10

Error returned from the API :

Field 'Created' cannot be referenced in filter or orderby as it is not indexed. Provide the 'allowthrottleablequeries' preference to allow this, but be warned that such queries may fail on large lists.

How to enable allowthrottleablequeries as it says and how should I achieve this?

2

2 Answers

1
votes

I'm afraid this isn't a very clear or useful error message. As far as I know, there isn't actually a way to enable allowthrottleablequeries.

This happens when a SharePoint list grows too large to handle filtering or sorting non-indexed columns. The fix is to add an index to the created column in your List Settings. You can find instructions on how to accomplish this in Add an index to a SharePoint column.

0
votes

Try to send your request with following Request Header

Prefer: allowthrottleablequeries

If it does not work then try the following Request Header

Prefer: HonorNonIndexedQueriesWarningMayFailRandomly