Why has ResetRoleInheritance stopped working on Sharepoint Online folders?

45 views Asked by At

I have a multitenant webapp, with multiple customers, that connects to the customers sharepoint online, using MS Graph for most part. One part that is not supported in Graph is ResetRoleInheritance, and I've made it work, using the Microsoft.Sharepoint.Client and this code:

// sharepointFolder id comes from MS Graph folder Id
// groupId is a site id
// client is a MS Graph client
var folder = await client.Groups[groupId].Drive.Items[sharepointFolderId].Request()
    .Select("sharepointIds").GetAsync().ConfigureAwait(false); // Get sharepoint ids
var authManager = new AuthenticationManager(Office365AppId,
    Certificates.LoadCertificate(), Office365TenantId);
using (var context =
        await authManager.GetContextAsync(folder.SharepointIds.SiteUrl).ConfigureAwait(false))
{
    Folder item = context.Web.GetFolderById(new Guid(folder.SharepointIds.ListItemUniqueId));
    context.Load(item.ListItemAllFields, p => p.HasUniqueRoleAssignments);
    context.ExecuteQuery();
    if (item.ListItemAllFields
        .HasUniqueRoleAssignments)
    {
        item.ListItemAllFields.ResetRoleInheritance();
        context.ExecuteQuery(); // This will fail
    }
}

This has worked fine until a couple of months ago. Now I always get this response from the server:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Request Error</title>
    <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
  </head>
  <body>
    <div id="content">
      <p class="heading1">Request Error</p>
      <p>The server encountered an error processing the request. See server logs for more details.</p>
    </div>
  </body>
</html>

This happens on all tenants, so I suspect that MS has changed something. I've tried from Postman too, with the REST API:

https://xxxxxx.sharepoint.com/sites/xxxxxxxxxx/_api/web/GetFolderById('{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}')/ListItemAllFields/ResetRoleInheritance

and that results in:

500 Internal server Error

Does anyone have an answer to this, or an alternative way to do it?

0

There are 0 answers