When making the call to initialize multiple user personal sites, I'm receiving the following error back:
[ { "SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.7324.1200","ErrorInfo":{ "ErrorMessage":"Access denied. You do not have permission to perform this action or access this resource.","ErrorValue":null,"TraceCorrelationId":"03ab459e-7076-5000-c1a7-196f1fc54384","ErrorCode":-2147024891,"ErrorTypeName":"System.UnauthorizedAccessException" },"TraceCorrelationId":"03ab459e-7076-5000-c1a7-196f1fc54384" } ]
I'm following the example here: https://docs.microsoft.com/en-us/sharepoint/dev/general-development/what-s-new-for-developers-in-social-and-collaboration-features-in-sharepoint-201
Note: mySiteUrl is equal to https://{tenantName}.sharepoint.com, tenantName being the name of the tenant.
using (var ct = new ClientContext(mySiteRootUrl))
{
var emails = xnl.ToList().Select(x => $"{XmlHelper.GetAttribute(x, "AccountName")}@{userDomain}").ToArray();
var securePass = new SecureString();
Array.ForEach(context.Password.ToCharArray(), c => securePass.AppendChar(c));
var credentials = new SharePointOnlineCredentials($"{adminAccountName}@{userDomain}", securePass);
ct.Credentials = credentials;
var web = ct.Web;
ct.Load(web);
ct.ExecuteQuery();
ProfileLoader loader = ProfileLoader.GetProfileLoader(ct);
if (loader == null)
{
throw new InvalidOperationException("Failed to get ProfileLoader");
}
loader.CreatePersonalSiteEnqueueBulk(emails);
ct.ExecuteQuery();
}
My code above is pretty closely mapped to the code in the example. The user I'm logged in with is the Global Admin, but yet I get an Access Denied error. Any ideas?
Thanks in advance.