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

yngrdyn
  • 918
  • 1
  • 16
  • 36
  • http://sharepoint.stackexchange.com/questions/129309/how-to-get-permission-of-a-sharepoint-list-for-a-user-using-rest-api – Amal Hashim Apr 23 '15 at 22:47

1 Answers1

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));
});
Vadim Gremyachev
  • 42,498
  • 3
  • 86
  • 167