Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,618 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am currently trying to retrieve all of the sites in a tenant using the method below. I am currently using the beta API, but I have also tried using the v1.0 API as well. I have all of the required permissions assigned to the app being, Sites.ReadWrite.All.
Currently I am getting on some of the sites but not all of them,
public static async Task<string> GetAllSitesAsync()
{
//21 sites to fetch
if (!isInitialised)
{
throw new InvalidOperationException("APICaller is not initialised. Call Initialise method first.");
}
try
{
var sites = await graphHandler.GraphClient.Sites.GetAllSites.GetAsGetAllSitesGetResponseAsync();
var options = new JsonSerializerOptions
{
WriteIndented = true
};
var json = JsonSerializer.Serialize(sites, options);
return json;
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
return string.Empty;
}
}
I have also tried to use
var result = await graphClient.Sites.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "*" };
});
Which again returns some sites that are not previously returned. But also some sites are not returned in either.
Any help would be kindly appreciated.