Syed Mauze Rehan
Syed Mauze Rehan

Reputation: 1145

Getting MSOL users through REST API for Sharepoint

I'm looking for a REST call to get all MS-Online users.

I am able to get these users through the following Powershell command

Get-MSOLUser -All

I am currently using http://{siteurl}/_api/web/siteusers call to fetch users, but this doesn't return all users that I get using Powershell.

Is there a way I could get all those users?

NOTE: One thing that I have noted is that /siteusers call doesn't return those users who haven't created a personal site(Onedrive) or in other words, returns only those users who have a /personal/user_name_domain_com site.

Could this be the reason why /siteusers call is not returning this data while Powershell is?

Upvotes: 0

Views: 1498

Answers (1)

Syed Mauze Rehan
Syed Mauze Rehan

Reputation: 1145

I figured it out myself! The trick is to use Graph API. Refer to Azure Graph API for users.

Get an access token for "https://graph.windows.net" resource. This access token can then be used to access https://graph.windows.net

Url to hit

Domain should be something like abc.onmicrosoft.com

Headers

  • Content-Type : application/json;odata=verbose Note::(application/json will do)
  • Authorization : Bearer eYrvwvZ_PN9Ty5a2pQrb23y******

Upvotes: 3

Related Questions