1

How can i get the group permissions for a list using an AJAX request with the REST API?

I could add or remove permissions for the group but i want to know the actual permissions of the group over the list

1

1 Answer 1

1

You could use the following endpoint for getting Folder permissions:

/_api/Web/GetFolderByServerRelativeUrl('<folder url>')/ListItemAllFields/RoleAssignments

Example

The following example demonstrates how to retrieve permissions details including Member and RoleDefinitionBindings info for a Folder and print it:

function getJson(url) 
{
    return $.ajax({       
       url: url,   
       type: "GET",  
       contentType: "application/json;odata=verbose",
       headers: { 
          "Accept": "application/json;odata=verbose"
       }
    });
}

var folderUrl = '/news/documents/2015';  //set server relative url of folder
var endpointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/GetFolderByServerRelativeUrl('" + folderUrl + "')/ListItemAllFields/RoleAssignments?$expand=Member,RoleDefinitionBindings"
getJson(endpointUrl)
.done(function(data)
{
    var items = data.d.results; 
    items.forEach(function(item){
        console.log('Member: ' + item.Member.Title);
        //print permission levels for member
        item.RoleDefinitionBindings.results.forEach(function(roleDefBindings){
            console.log(roleDefBindings.Name);
        });
        console.log('---');    
    });

})
.fail(
function(error){
    console.log(JSON.stringify(error));
});
2
  • I'm not working with folders, just with lists
    – yngrdyn
    Commented Apr 24, 2015 at 17:09
  • What about for a site collection?
    – BeerusDev
    Commented Sep 8, 2022 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.