Thursday, November 12, 2015

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

I have encountered this issue with my SharePoint 2013 server farm. Code was working fine with the development machine but once it deployed to Share Point 2013 production environment; 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.executeQueryAsync(onQuerySucceeded, onQueryFailed);


Message was straight forward so I thought it is a permission issue. When I logged using my credentials It was fine and worked but when I logged out and view as a Anonymous user it didn’t work.

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

then I 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()
I ran this script in the App server and it worked.