Thursday, August 3, 2017

Anonymous Access for Client Object Model in SharePoint

Have you ever faced this error failed Message: The method “GetItems” of the type “List” with ID {GUID} is blocked by administrator on the server.on public facing site ?

So apparently anonymous users, using the Client Object Model, are blocked from using

    GetItems and GetChanges on SPLists
    GetChanges and GetSubwebsForCurrentUser on SPWebs
    GetChanges on SPSites

The good news, however, is that the ClientCallableSettings value can be adjusted to allow anonymous user access to one or more of these methods.
Doing this with PowerShell:
$webapp = Get-SPWebApplication "http://sp2013dev"
$webapp.ClientCallableSettings.AnonymousRestrictedTypes.Remove([microsoft.sharepoint.splist], "GetItems")
$webapp.Update()
Be sure to replace "http://sp2013dev" with whatever url your target webapp has. After doing this, anonymous calls to GetItems will work for that web application. The changes are persisted in the SharePoint database, and last until you change the setting again, or recreate the web application.