SOLVED

Sharepoint API - REST

%3CLINGO-SUB%20id%3D%22lingo-sub-358446%22%20slang%3D%22en-US%22%3ESharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358446%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BI%20am%20trying%20to%20access%20sharepoint%20REST%20api%20using%20OAuth.%20I%20am%20getting%20401%20unauthorized%20exception%20when%20I%20try%20to%20call%20the%20url%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CP%3E%3CU%3E%3CA%20href%3D%22https%3A%2F%2F%253c%253ctenant%253e%253e.sharepoint.com%2Fsites%2Fpub1%2F_api%2FWeb%2FSiteGroups%2FGetById(%253c%253cgroupid%253e%253e)%2Fusers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2F%26lt%3B%3CTENANT%3E%26gt%3B.sharepoint.com%2Fsites%2Fpub1%2F_api%2FWeb%2FSiteGroups%2FGetById(%26lt%3B%3CGROUPID%3E%26gt%3B)%2Fusers%3C%2FGROUPID%3E%3C%2FTENANT%3E%3C%2FA%3E%3C%2FU%3E%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20this%20need%20%22full%20control%22%20permissions%3F%20Attached%20are%20the%20permissions%20setup%20in%20azure%20portal.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-358446%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharepoint%20REST%20API%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358539%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358539%22%20slang%3D%22en-US%22%3EThank%20you!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358524%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358524%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F282907%22%20target%3D%22_blank%22%3E%40Taron1645%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%20this%20case%20you're%20permission%20settings%20is%20not%20correct.%3C%2FP%3E%3CP%3EPlease%20use%20this%20one%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20406px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84726i329FAE1ACE30CFF3%2Fimage-dimensions%2F406x63%3Fv%3D1.0%22%20width%3D%22406%22%20height%3D%2263%22%20alt%3D%22Cattura.PNG%22%20title%3D%22Cattura.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358510%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358510%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Frederico%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I%20made%20a%20basic%20call%20to%20_api%2FWeb%20to%20couple%20of%20sites%2C%20I%20am%20getting%20similar%20results.%20One%20is%20successful%2C%20the%20other%20is%20401%20error.%20I%20am%20using%20Client%2FSecret%2FCerts%20for%20authentication.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358506%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358506%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F282907%22%20target%3D%22_blank%22%3E%40Taron1645%3C%2FA%3E%3C%2FP%3E%3CP%3E%2F_api%2FWeb%2FSiteGroups%2F%20tipical%20needs%20the%20setting%20I%20share%20with%20you%2C%20if%20the%20user%20is%20not%20a%20group%20member.%3C%2FP%3E%3CP%3ECould%20you%20try%20to%20make%20a%20basic%20call%20i.e.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fyyyy.sharepoint.com%2Fsites%2Fdept%2FXXXX%2F_api%2FWeb%2FSiteGroups%2FGetById(6180)%2FUsers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fyyyy.sharepoint.com%2Fsites%2Fdept%2FXXXX%2F_api%2FWeb%3C%2FA%3E%20for%20every%20sites%3F%3C%2FP%3E%3CP%3EAre%20you%20using%20client%20%2F%20secret%20for%20authentication%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358504%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358504%22%20slang%3D%22en-US%22%3E%3CP%3EYes%20the%20issue%20is%20that%20I%20am%20able%20to%20access%20certain%20sites%20and%20get%20successful%20response%26nbsp%3Band%20getting%20401%20unauthorized%20for%20others.%20I%20am%20not%20sure%20where%20the%20problem%20is.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBelow%20is%20the%20endpoint%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fyyyy.sharepoint.com%2Fsites%2Fdept%2FXXXX%2F_api%2FWeb%2FSiteGroups%2FGetById(6180)%2FUsers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fyyyy.sharepoint.com%2Fsites%2Fdept%2FXXXX%2F_api%2FWeb%2FSiteGroups%2FGetById(6180)%2FUsers%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358493%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358493%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F282907%22%20target%3D%22_blank%22%3E%40Taron1645%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20Did%20you%20call%20correctly%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2F%253c%253ctenant%253e%253e.sharepoint.com%2Fsites%2Fpub1%2F_api%2FWeb%2FSiteGroups%2FGetById(%253c%253cgroupid%253e%253e)%2Fusers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2F%26lt%3B%3CTENANT%3E%26gt%3B.sharepoint.com%2Fsites%2Fpub1%2F_api%2FWeb%2F%3C%2FTENANT%3E%3C%2FA%3E%20%2C%20without%20permissions%20problems%3F%3C%2FP%3E%3CP%3E2)%20You%20can%20access%20to%20group%20settings%20in%20this%20way%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSPAN%3ESelect%20Site%20Actions%20%26gt%3B%20Site%20Settings%20%26gt%3B%20People%20and%20Groups.%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3ESelect%20Settings%20%26gt%3B%20Group%20Settings%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EFor%20each%20group%20listed%2C%20%3C%2FSPAN%3E%3CSPAN%3ENavigate%20to%20%22Who%20can%20view%20the%20membership%20of%20the%20group%3F%22%20section.%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%3ECheers%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFederico%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358490%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358490%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3EHi%20Frederico%2C%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Thanks%20for%20the%20response.%20Where%20can%20I%20see%20the%20group%20settings%3F%20For%20the%20AD%20application%20I%20am%20testing%20against%2C%20I%20see%20one%20user%20and%20role%20assigned%20is%20Default%20Access.%20Attached%20screenshot.%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358485%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20API%20-%20REST%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358485%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F282907%22%20target%3D%22_blank%22%3E%40Taron1645%3C%2FA%3E%20%2C%3C%2FP%3E%3CP%3Eazure%20permission%20looks%20good.%3C%2FP%3E%3CP%3ETry%20to%20change%20group%20settings%20from%20%22Group%20Members%22%20to%20%22Everyone%22%3C%2FP%3E%3CP%3E%3CIMG%20alt%3D%22Risultati%20immagini%20per%20sharepoint%20spgroup%20see%20users%22%20src%3D%22https%3A%2F%2Fspjsblog.com%2Fwp-content%2Fuploads%2F2016%2F01%2FWho-can-view-the-membership-of-the-group.png%22%20border%3D%220%22%20%2F%3E%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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 (Occasional Contributor)
Solution

Hi @Taron1645 

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

Please use this one

Cattura.PNG

 

Cheers,

Federico

Thank you!