尝试获取SiteGroup /用户时,Sharepoint在线REST API System.UnauthorizedAccessException

时间:2018-11-07 10:19:05

标签: sharepoint sharepoint-online sharepoint-rest-api

我正在尝试通过调用以下REST API从Sharepoint Online获取SiteGroup /用户: / _api / web?$ expand =网站,列表,所有属性,ThemeInfo,SiteUsers,SiteGroups,SiteGroups / Users,RoleDefinitions&$ select = *

虽然在某些客户的共享站点上,它可以正常工作,但在其他客户上却失败了:

{"error":{"code":"-2147024891, System.UnauthorizedAccessException","message": 
{"lang":"en-US","value":"Access denied. You do not have permission to perform 
this action or access this resource."}}}

当我删除SiteGroups / Users时,它工作正常,但是我需要SiteGroups / Users。在这两种情况下,我访问的用户都是网站集管理员。因此,我试图了解管理员之间的区别,在一种情况下可以正常运行,而在另一种情况下则可以。 谢谢

1 个答案:

答案 0 :(得分:-1)

发生这种情况是因为您在错误的网址上注册了应用程序,例如,如果您的 SharePoint 文件基网址是 https://yourtenantname.sharepoint.com/sites/yourfoldername 然后使用此网址进行应用注册https://yourtenantname.sharepoint.com/sites/yourfoldername/_layouts/15/appregnew.aspx,而不是此 https://yourtenantname.sharepoint.com/_layouts/15/appregnew.aspx

您可以参考这篇文章注册您的应用程序以获取rest API: https://anoopt.medium.com/accessing-sharepoint-data-using-postman-sharepoint-rest-api-76b70630bcbf