Share via


Request failed. The method "GetItems" of the type "List" with id is blocked by the administrator on the server. SharePoint 2013

Request failed. The method "GetItems" of the type "List" with id is blocked by the administrator on the server. SharePoint 2013

We have encountered this issue with a SharePoint 2013 server farm. The code was working fine with the development machine but once it deployed to SharePoint 2013 production environment we found this error on Chrome console.

function somefunc()
{
    listItems = '' ;
    
   var context = SP.ClientContext.get_current();
   var web = context.get_web(); 
   var currentList = web.get_lists().getById(_spPageContextInfo.pageListId);
   var query = new SP.CamlQuery();
   listItems = currentList.getItems();
   context.load(listItems);
   context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}

The message was straight forward so we thought it was a permission issue. When logging in using credentials it was fine and worked. But when logging out and view as an Anonymous user it didn’t work.

Then tried to give permission to EveryOne to the list, even for the site collection, and it didn’t work either.

Then found out it’s a property in web application which handles the Anonymous calls to the Web Application and it’s the Microsoft.SharePoint.Administration.SPClientCallableSettings class.

Using a simple PowerShell you can remove these properties and make it work.

$webappllication = Get-SPWebApplication "http://sp2013"
$webappllication .ClientCallableSettings.AnonymousRestrictedTypes.Remove([microsoft.sharepoint.splist], "GetItems")
$webappllication .Update()

Ran this script in the app server and it worked.