SharePoint Online: REST API for List, calling Filters and limit the return items

前端 未结 3 1235
野趣味
野趣味 2021-02-11 03:01

I am trying to call REST API for list using below REST API

https://myweb.sharepoint.com/teams/sites/subwebs/_api/web/lists/GetByTitle(\'MyList\')/Items?
$top=1
&         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-11 03:17

    The exception Microsoft.SharePoint.SPQueryThrottledException is thrown since $filter=Title eq 'Female' query causes to walk through the whole list and check every row to see if it matches.

    According to MSDN:

    The list view threshold does not apply simply to the number of results returned by your query. Instead, it restricts the numbers of database rows that can be accessed in order to complete execution of the query at the row level in the content database.

    That's why $top query option is not applicable here.

    One option to avoid the issue would be indexing the Title field.

    Go to List Settings -> Indexed Columns -> Create a new index -> select Title as a Primary Column:

    Once Title field is indexed, the following query should succeed:

    https://site/_api/web/lists/GetByTitle('')/Items?$top=1&$orderby=ID&$select=ID,Title&$filter=Title eq ''
    

提交回复
热议问题