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
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityHow 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
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));
});