SOLVED

Sharepoint API - REST

Copper Contributor

Hello,

 

           I am trying to access sharepoint REST api using OAuth. I am getting 401 unauthorized exception when I try to call the url

 

https://<<tenant>>.sharepoint.com/sites/pub1/_api/Web/SiteGroups/GetById(<<groupid>>)/users

 

Does this need "full control" permissions? Attached are the permissions setup in azure portal.

 

 

 

 

8 Replies

Hi @Taron1645 ,

azure permission looks good.

Try to change group settings from "Group Members" to "Everyone"

Risultati immagini per sharepoint spgroup see users

Cheers,

Federico

Hi Frederico,

 

              Thanks for the response. Where can I see the group settings? For the AD application I am testing against, I see one user and role assigned is Default Access. Attached screenshot.

Hi @Taron1645 

1) Did you call correctly https://<<tenant>>.sharepoint.com/sites/pub1/_api/Web/ , without permissions problems?

2) You can access to group settings in this way

  • Select Site Actions > Site Settings > People and Groups.
  • Select Settings > Group Settings
  • For each group listed, Navigate to "Who can view the membership of the group?" section.

Cheers,

Federico

Yes the issue is that I am able to access certain sites and get successful response and getting 401 unauthorized for others. I am not sure where the problem is.

 

Below is the endpoint

https://yyyy.sharepoint.com/sites/dept/XXXX/_api/Web/SiteGroups/GetById(6180)/Users

Hi @Taron1645

/_api/Web/SiteGroups/ tipical needs the setting I share with you, if the user is not a group member.

Could you try to make a basic call i.e. https://yyyy.sharepoint.com/sites/dept/XXXX/_api/Web for every sites?

Are you using client / secret for authentication?

Hi Frederico,

 

         I made a basic call to _api/Web to couple of sites, I am getting similar results. One is successful, the other is 401 error. I am using Client/Secret/Certs for authentication.

 

 

best response confirmed by Taron1645 (Copper Contributor)
Solution

Hi @Taron1645 

in this case you're permission settings is not correct.

Please use this one

Cattura.PNG

 

Cheers,

Federico

Thank you!
1 best response

Accepted Solutions
best response confirmed by Taron1645 (Copper Contributor)
Solution

Hi @Taron1645 

in this case you're permission settings is not correct.

Please use this one

Cattura.PNG

 

Cheers,

Federico

View solution in original post