Break Role Assignment Inheritance In SharePoint 2013 Online Using REST API

You can break the security inheritance of a Web site, list or list item through the BreakRoleInheritance method of the object, so that role assignments on the parent object no longer applies to the child object.

For example, role assignments on a list no longer applies to a list item.

To use the example in this blog, you'll need,
  1. A SharePoint 2013 development environment (app isolation required for On-Premises scenario).
  2. Visual Studio 2012 or Visual Studio 2013 with Office Developer tools for Visual Studio 2012.
  3. Napa (SharePoint Online only).
  4. You'll also need to set full control add-in permissions at the Web scope. Only the users who have sufficient permissions to change the list permissions (such as site owners) can run this add-in.
  1. var siteUrl = 'http://gowthamr.SharePoint.com';  
  2. var listTitle = 'Tutorial List';  
  3. var groupName = 'Gowthamr Owners';  
  4. var targetRoleDefinitionName = 'Contribute';  
  5. var groupId;  
  6. var targetRoleDefinitionId;  
  7.   
  8. $(document).ready( function() {  
  9.     breakRoleInheritanceOfList();  
  10. });  
  11.   
  12.   
  13. function breakRoleInheritanceOfList() {  
  14.     $.ajax({  
  15.         url: siteUrl + '/_api/web/lists/getbytitle(\'' + listTitle  
  16.             + '\')/breakroleinheritance(true)',  
  17.         type: 'POST',  
  18.         headers: { 'X-RequestDigest':$('#__REQUESTDIGEST').val() },  
  19.         success: successHandler(),    
  20.         error: errorHandler  
  21.     });  
  22. }  
  23.    
  24. function successHandler() {  
  25.      alert('Request succeeded Successfully.');  
  26. }   
  27.   
  28. function errorHandler(xhr, ajaxOptions, thrownError) {  
  29.     alert('Request failed: ' + xhr.status + '\n' + thrownError + '\n' + xhr.responseText);  
  30. }   
Was my blog helpful?

If so, please let us know at the bottom of this page. If not, let us know what was confusing or missing and I’ll use your feedback to double-check the facts, add info and update this blog.