sites: getAllSites
本文内容
列出组织中跨地理位置 的网站 。 此 API 还可用于枚举非多地理位置租户中的所有站点。
有关详细信息,请参阅发现 文件和大规模检测更改的最佳做法 。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
✅
权限
为此 API 选择标记为最低特权的权限。 只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
不支持。
不支持。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
Sites.Read.All
Sites.ReadWrite.All
HTTP 请求
GET /sites/getAllSites
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
示例
示例 1:初始请求
请求
GET https://graph.microsoft.com/v1.0/sites/getAllSites
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites.GetAllSites.GetAsGetAllSitesGetResponseAsync();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
getAllSites, err := graphClient.Sites().GetAllSites().GetAsGetAllSitesGetResponse(context.Background(), nil)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
var result = graphClient.sites().getAllSites().get();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let getAllSites = await client.api('/sites/getAllSites')
.get();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->sites()->getAllSites()->get()->wait();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
from msgraph import GraphServiceClient
graph_client = GraphServiceClient(credentials, scopes)
result = await graph_client.sites.get_all_sites.get()
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
响应
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "contoso-apc.sharepoint.com,bf6fb551-d508-4946-a439-b2a6154fc1d9,65a04b8b-1f44-442b-a1fc-9e5852fb946c",
"name": "Root Site",
"isPersonalSite": false,
"root": { },
"siteCollection": {
"hostName": "contoso-apc.sharepoint.com",
"dataLocationCode": "APC",
"root": { }
},
"webUrl": "https://contoso-apc.sharepoint.com"
},
{
"id": "contoso-apc.sharepoint.com,d9ecf079-9b13-4376-ac5d-f242dda55626,746dbcc1-fa2b-4120-b657-2670bae5bb6f",
"name": "Site A",
"isPersonalSite": false,
"root": { },
"siteCollection": {
"hostName": "contoso-apc.sharepoint.com"
},
"webUrl": "https://contoso-apc.sharepoint.com/sites/siteA"
},
{
"id": "contoso-apc.sharepoint.com,fd1a778f-263e-4c43-acdf-d5c2519d80eb,c06016db-dfec-4f79-83a1-09c6dbfd7022",
"name": "Site B",
"isPersonalSite": false,
"root": { },
"siteCollection": {
"hostName": "contoso-apc.sharepoint.com"
},
"webUrl": "https://contoso-apc.sharepoint.com/sites/siteB"
}
],
"@odata.nextLink": "https://graph.microsoft.com/v1.0/sites/oneDrive.getAllSites?$skiptoken=U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ"
}
此响应包括枚举网站的第一页,属性 @odata.nextLink 指示当前项集中有更多项可用。 你的应用应继续请求 的 URL 值, @odata.nextLink 直到检索到项目的所有页面。
示例 2:后续请求
请求
GET /sites/getAllSites?$skiptoken=U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
// Note: The URI string parameter used with WithUrl() can be retrieved using the OdataNextLink or OdataDeltaLink property from a response object
var result = await graphClient.Sites.GetAllSites.WithUrl("https://graph.microsoft.com/v1.0/sites/getAllSites?$skiptoken=U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ").GetAsGetAllSitesGetResponseAsync();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphsites "github.com/microsoftgraph/msgraph-sdk-go/sites"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestSkiptoken := "U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ"
requestParameters := &graphsites.SitesGetAllSites()RequestBuilderGetQueryParameters{
Skiptoken: &requestSkiptoken,
}
configuration := &graphsites.SitesGetAllSites()RequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
getAllSites, err := graphClient.Sites().GetAllSites().GetAsGetAllSitesGetResponse(context.Background(), configuration)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
var result = graphClient.sites().getAllSites().get(requestConfiguration -> {
requestConfiguration.queryParameters.skiptoken = "U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ";
});
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let getAllSites = await client.api('/sites/getAllSites')
.skiptoken('U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ')
.get();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Sites\GetAllSites\GetAllSitesRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GetAllSitesRequestBuilderGetRequestConfiguration();
$queryParameters = GetAllSitesRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->skiptoken = "U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->sites()->getAllSites()->get($requestConfiguration)->wait();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.Sites
Get-MgAllSite -Skiptoken "U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ"
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
from msgraph import GraphServiceClient
from msgraph.generated.sites.get_all_sites.get_all_sites_request_builder import GetAllSitesRequestBuilder
graph_client = GraphServiceClient(credentials, scopes)
query_params = GetAllSitesRequestBuilder.GetAllSitesRequestBuilderGetQueryParameters(
skiptoken = "U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ",
)
request_configuration = GetAllSitesRequestBuilder.GetAllSitesRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.sites.get_all_sites.get(request_configuration = request_configuration)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
响应
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "contoso-nam.sharepoint.com,bf6fb551-d508-4946-a439-b2a6154fc1d9,65a04b8b-1f44-442b-a1fc-9e5852fb946c",
"name": "Root Site",
"isPersonalSite": false,
"root": { },
"siteCollection": {
"hostName": "contoso-nam.sharepoint.com",
"dataLocationCode": "NAM",
"root": { }
},
"webUrl": "https://contoso-nam.sharepoint.com"
},
{
"id": "contoso-nam.sharepoint.com,d9ecf079-9b13-4376-ac5d-f242dda55626,746dbcc1-fa2b-4120-b657-2670bae5bb6f",
"name": "Site A",
"isPersonalSite": false,
"root": { },
"siteCollection": {
"hostName": "contoso-nam.sharepoint.com"
},
"webUrl": "https://contoso-nam.sharepoint.com/sites/siteA"
},
{
"id": "contoso-nam.sharepoint.com,fd1a778f-263e-4c43-acdf-d5c2519d80eb,c06016db-dfec-4f79-83a1-09c6dbfd7022",
"name": "Site B",
"isPersonalSite": false,
"root": { },
"siteCollection": {
"hostName": "contoso-nam.sharepoint.com"
},
"webUrl": "https://contoso-nam.sharepoint.com/sites/siteB"
}
],
"@odata.nextLink": "https://graph.microsoft.com/v1.0/sites/oneDrive.getAllSites?$skiptoken=U1BHZW9EYXRhTG9jYXRpb25Db2RlYU5BTQ"
}