Pages

Tuesday, September 5, 2017

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

Introduction

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.

Problem

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


Solution

Step 1

Go to “People and groups” under Site Setting.

Step 2

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

image

Step 3

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

image

Step 4

Click OK

Conclusion

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

image

No comments:

Post a Comment