SharePoint REST GetItems with Anonymous Access – ApiBlockedException

When you have your SharePoint application enabled with Anonymous access, often can occur the exception:

Microsoft.Sharepoint.Client.ApiBlockedException

This is, because some Rest methods can be disabled on web application scope. You can run this commands, to show
list, which methods are not approved:

$webapp = Get-SPWebApplication "Url of your app"
$webapp.ClientCallableSettings.AnonymousRestrictedTypes

FullName                    : Microsoft.SharePoint.SPList
MethodNames                 : {GetItems, GetChanges}
GetPropertyNames            : {}
SetPropertyNames            : {}
UpgradedPersistedProperties :
...

Line MethodNames indicates, that GetItems and GetChanges are forbidden on SPList object.

You can enable them by using this command:

$webapp.ClientCallableSettings.AnonymousRestrictedTypes.Remove([microsoft.sharepoint.splist], "GetItems")
$webapp.Update()

Now, your Rest query to GetItems should be working.


Leave a Reply

Your email address will not be published. Required fields are marked *

About me

I am web developer, tech enthusiast and fitness junkie 🙂

Calendar

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031