I have trouble with the graph api /sites?search= call.
In fact, my request returns only 11 sites out of 16. I don’t see the difference between these sites that could explain this.
I connect with the credentials of an application (client secret) on the api and I have the Sites.ReadWriteAll (Application) permission.
Maybe the application doesn’t have access to certain sites and needs to be explicitly granted somewhere on Azure? Any help is welcome.
2
Answers
I registered one Azure AD application and granted Sites.ReadWrite.All permission of Application type:
Now, I generated access token using client credentials flow via Postman with below parameters:
Response:
When I used the above token to call graph API with search query, I got only 16 sites out of 21:
Response:
As @user2250152 suggested, you can make use of
GetAllSites
endpoint to list all sites across geographies in an organization.Response:
I got the same results when I used below graph call as all sites are in same geographic location:
Response:
When I checked the difference between these sites, I observed
/sites?search=
call won’t return sites that are created for user’s personal OneDrive accounts that looks like:This
/sites?search=
call also won’t return below search site:But
GetAllSites
andListAllSites
endpoint returns all these sites in response.Reference:
Try to retrieve all sites, but in some cases, some sites are not found in the search – Microsoft Q&A by RajeshKumar-MSFT
Try to add Sites.Read.All, Sites.ReadWrite.All & Sites. Selected Permissions. If you don’t have the permission to the site, you will be unable to search the site