Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied, You do not have permission to perform this action or access this resource

This SharePoint tutorial explains how to resolve issue Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied, You do not have permission to perform this action or access this resource.

The error comes in while creating a term store using PnP CSOM in SharePoint Online Office 365. The error looks like below:

Access denied error while creating term store sharepoint
Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied, You do not have permission to perform this action or access this resource

I wrote the below code to create groups, term sets, terms etc using SharePoint CSOM using PnP SharePoint Office 365.

if (termStore != null)
{					
// Create group, termset, and terms.			
//TermStore store = taxonomySession.GetDefaultKeywordsTermStore();

TermGroup myGroup = termStore.CreateGroup("TSInfo Group", Guid.NewGuid());
TermSet myTermSet = myGroup.CreateTermSet("Brand", Guid.NewGuid(), 1033);
myTermSet.CreateTerm("TV", 1033, Guid.NewGuid());
myTermSet.CreateTerm("Camera", 1033, Guid.NewGuid());
myTermSet.CreateTerm("Fridge", 1033, Guid.NewGuid());
myTermSet.CreateTerm("Washing Machine", 1033, Guid.NewGuid());
cc.ExecuteQuery();																			
} 

Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied, You do not have permission to perform this action or access this resource

I am a global administrator in Office 365 tenant. But still, the error was coming.

For this, you need to be a member of “Term Store Administrators”.

Open SharePoint Online Admin site and click on Term Store from left navigation. The URL looks like: https://-admin.sharepoint.com/_layouts/15/termstoremanager.aspx

Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied
Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied

There you will see Term Store Administrator, add the user name here.

Access Denied, You do not have permission to perform this action or access this resource
Access Denied, You do not have permission to perform this action or access this resource

Now if you will run the code the error “Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied, You do not have permission to perform this action or access this resource” will not come and you can able to create groups, term sets or terms.

Note: Even if you are a global administrator, you can add terms unless you are in Term Store Administrator group.

You may like following SharePoint Tutorials:

I hope this SharePoint Online tutorial helps to resolve error Microsoft.SharePoint.Client.ServerUnauthorizedAccessException. Access Denied, You do not have permission to perform this action or access this resource.

>