Tuesday, September 5, 2017

Access SharePoint group users from SharePoint Hosted Add-in through Rest API


I was using SharePoint rest api in order to read the users from a SharePoint group.


   var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getbyname('" + groupName + "')/users";

We can use the Add-in web url since the groups are inherited from the parent site (Host web) to the add-in web.


When a user (other than the site collection administrator) try to access the above rest url, it throws access denied exception.

Access denied when trying to get users from SharePoint group


Step 1

Go to “People and groups” under Site Setting.

Step 2

Select the group and then go to “Group Setting” under Setting.


Step 3

Then select “Everyone” radio button for the "Who can view the membership of the group?" option.


Step 4

Click OK


Now other users also will have  the permission to read the users in the group.


No comments:

Post a Comment