I need to filter a list which has more than 5000 items using SharePoint REST API
One of the columns to filter is a managed metadata column which prevents me from using SharePoint REST API GET Urls
I have to use REST API POST requests with CAML Query in the body to achieve this.
My code looks like below
var viewXml =
{
ViewXml: "<View>" +
"<Query>" +
"<Where><Eq>" +
"<FieldRef Name='RegionTestHidden'/>" +
"<Value Type='TaxonomyFieldType'>" + "North" + "</Value>" +
"</Eq></Where>" +
"</Query>" +
"</View>"
}
function CamlQueryRESTCall(listName, viewXml)
{
var call = jQuery.ajax(
{
url: _spPageContextInfo.webAbsoluteUrl+ "/_api/Web/Lists/getByTitle('"+listName+"')/GetItems(query=@v1)?" +
"@v1=" + JSON.stringify(viewXml),
type: "POST",
dataType: "json",
headers:
{
Accept: "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
}
}
);
return call;
}
The problem I am encountering is if i filter based on region South
which has more than 5000 items as result, I am getting HTTP Error 500 Internal Server Error
with error message List item threshold exceeded
.
With the GET requests I can use $top
and data.d.__next
to load more than 5000 items. But how to do similar logic in POST requests?
I tried including <RowLimit>1000</RowLimit>
in the CAML Query but still same error
The columns used in query are indexed btw.
This is due to the List view threshold that SharePoint has. See here
It is a threshold and you can change that to fit your needs. This is done in Central Admin like this: