You could consider the following approach to get List permission levels/roles:
- get the List effective permissions using
/_api/web/lists/getbytitle('<list title>')/getusereffectivepermissions
endpoint
- determine user roles using SP.BasePermissions.has(perm) Method
JavaScript example
function getListUserEffectivePermissions(webUrl,listTitle, accountName)
{
var endpointUrl = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getusereffectivepermissions(@u)?@u='" + encodeURIComponent(accountName) + "'";
return $.getJSON(endpointUrl);
}
function parseBasePermissions(value)
{
var permissions = new SP.BasePermissions();
permissions.initPropertiesFromJson(value);
var permLevels = [];
for(var permLevelName in SP.PermissionKind.prototype) {
if (SP.PermissionKind.hasOwnProperty(permLevelName)) {
var permLevel = SP.PermissionKind.parse(permLevelName);
if(permissions.has(permLevel)){
permLevels.push(permLevelName);
}
}
}
return permLevels;
}
Usage
var webUrl = _spPageContextInfo.webAbsoluteUrl;
getListUserEffectivePermissions(webUrl,'Documents','i:0#.f|membership|[email protected]')
.done(function(data){
var roles = parseBasePermissions(data);
console.log(roles);
});
Result
["emptyMask", "viewListItems", "addListItems", "editListItems", "deleteListItems", "openItems", "viewVersions", "deleteVersions", "managePersonalViews", "viewFormPages", "open", "viewPages", "createSSCSite", "browseDirectories", "browseUserInfo", "addDelPrivateWebParts", "updatePersonalWebParts", "useClientIntegration", "useRemoteAPIs", "createAlerts", "editMyUserInfo"]