使用图表 api beta 获取 Sharepoint 管理中心中列出的所有根站点
Get all root sites listed in share point Admin center using graph api beta
我需要图像中显示的共享点管理中心中列出的所有根站点
为此,我正在使用 Graph api,如下所示,
var settings = {
"async": true,
"crossDomain": true,
"url": "https://graph.microsoft.com/beta/sharepoint/sites",
"method": "GET",
"headers": {
"authorization": "Bearer token",
"cache-control": "no-cache",
"postman-token": "3116b007-e574-5ad4-aedd-3b35fbf76b61"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
但它给出的输出如下,
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#sharePoint/sites",
"value": [
{
"createdDateTime": "2017-02-18T13:03:01.263Z",
"description": "",
"id": "2422c3a2-3c51-40f1-8483-5454aead43c4,412bb897-c754-460a-962d-db22893a1649",
"lastModifiedDateTime": "2017-04-24T02:16:43Z",
"name": "",
"webUrl": "https://mps330124.sharepoint.com",
"root": {},
"siteCollection": {
"hostname": "mps330124.sharepoint.com"
},
"siteCollectionId": "2422c3a2-3c51-40f1-8483-5454aead43c4",
"siteId": "412bb897-c754-460a-962d-db22893a1649"
}
]
}
如何使用 graph api beta
实现
您得到的不是错误。
如果您在 siteCollectionId
后面加上 URL https://graph.microsoft.com/beta/sharepoint/sites/2422c3a2-3c51-40f1-8483-5454aead43c4/sites,您将获得该网站集中的网站列表。
无法通过 Microsoft Graph 检索网站集的完整列表。该功能在 SharePoint API 中 "admin only",尚未通过 Microsoft Graph 提供。
我们正在对 Microsoft Graph 的 SharePoint 网站 API 进行一些更改,这些更改将在接下来的几周内推出,以便可以搜索网站/网站集列表,但是我们仍然没有计划提供通过 Microsoft Graph 枚举所有网站/网站集的能力。
观看 Change Log Build 2017 大会(5 月 10 日至 12 日),了解我们的所有详细信息。
现在似乎有一种方法可以通过以下请求获取顶级网站集的列表:
GET https://graph.microsoft.com/beta/sites?select=siteCollection,webUrl&filter=siteCollection/root%20ne%20null
下一页记录了这一点(9 月 19 日更新):https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/site_list
我自己的测试虽然没有取得任何成果,因为 API returns 一个 Cannot enumerate sites
错误。另一种方法是使用 search
查询参数(docs 于 9 月 20 日更新):
GET https://graph.microsoft.com/beta/sites?search=contoso&select=siteCollection,WebUrl&filter=siteCollection/root ne null
但这只为 root
提供了 siteCollection
:/ 并列出了所有 sites
及其 webUrl
的其他 siteCollection's
(像默认的 /sites
& /teams
) 但不是它们所属的 siteCollection
的实际 url/hostname。虽然可以从 webUrl
路径组件中提取。
在站点搜索端点上使用星号似乎可行
https://graph.microsoft.com/v1.0/sites?search=*
returns
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
"value": [
{
"createdDateTime": "2017-09-15T01:11:50Z",
"description": "Let's capture our thoughts in this subsite blog.",
"id": "xyz.sharepoint.com,5a58bb09-1fba-41c1-8125-69da264370a0,5e9767b8-95bc-4bd1-aeb0-defabcdefabc",
"lastModifiedDateTime": "0001-01-01T08:00:00Z",
"name": "internalblogs",
"webUrl": "https://xyz.sharepoint.com/internalblogs",
"displayName": "Internal blog"
},
{
...
}]
}
我需要图像中显示的共享点管理中心中列出的所有根站点
为此,我正在使用 Graph api,如下所示,
var settings = {
"async": true,
"crossDomain": true,
"url": "https://graph.microsoft.com/beta/sharepoint/sites",
"method": "GET",
"headers": {
"authorization": "Bearer token",
"cache-control": "no-cache",
"postman-token": "3116b007-e574-5ad4-aedd-3b35fbf76b61"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
但它给出的输出如下,
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#sharePoint/sites",
"value": [
{
"createdDateTime": "2017-02-18T13:03:01.263Z",
"description": "",
"id": "2422c3a2-3c51-40f1-8483-5454aead43c4,412bb897-c754-460a-962d-db22893a1649",
"lastModifiedDateTime": "2017-04-24T02:16:43Z",
"name": "",
"webUrl": "https://mps330124.sharepoint.com",
"root": {},
"siteCollection": {
"hostname": "mps330124.sharepoint.com"
},
"siteCollectionId": "2422c3a2-3c51-40f1-8483-5454aead43c4",
"siteId": "412bb897-c754-460a-962d-db22893a1649"
}
]
}
如何使用 graph api beta
实现您得到的不是错误。
如果您在 siteCollectionId
后面加上 URL https://graph.microsoft.com/beta/sharepoint/sites/2422c3a2-3c51-40f1-8483-5454aead43c4/sites,您将获得该网站集中的网站列表。
无法通过 Microsoft Graph 检索网站集的完整列表。该功能在 SharePoint API 中 "admin only",尚未通过 Microsoft Graph 提供。
我们正在对 Microsoft Graph 的 SharePoint 网站 API 进行一些更改,这些更改将在接下来的几周内推出,以便可以搜索网站/网站集列表,但是我们仍然没有计划提供通过 Microsoft Graph 枚举所有网站/网站集的能力。
观看 Change Log Build 2017 大会(5 月 10 日至 12 日),了解我们的所有详细信息。
现在似乎有一种方法可以通过以下请求获取顶级网站集的列表:
GET https://graph.microsoft.com/beta/sites?select=siteCollection,webUrl&filter=siteCollection/root%20ne%20null
下一页记录了这一点(9 月 19 日更新):https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/site_list
我自己的测试虽然没有取得任何成果,因为 API returns 一个 Cannot enumerate sites
错误。另一种方法是使用 search
查询参数(docs 于 9 月 20 日更新):
GET https://graph.microsoft.com/beta/sites?search=contoso&select=siteCollection,WebUrl&filter=siteCollection/root ne null
但这只为 root
提供了 siteCollection
:/ 并列出了所有 sites
及其 webUrl
的其他 siteCollection's
(像默认的 /sites
& /teams
) 但不是它们所属的 siteCollection
的实际 url/hostname。虽然可以从 webUrl
路径组件中提取。
在站点搜索端点上使用星号似乎可行
https://graph.microsoft.com/v1.0/sites?search=*
returns
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
"value": [
{
"createdDateTime": "2017-09-15T01:11:50Z",
"description": "Let's capture our thoughts in this subsite blog.",
"id": "xyz.sharepoint.com,5a58bb09-1fba-41c1-8125-69da264370a0,5e9767b8-95bc-4bd1-aeb0-defabcdefabc",
"lastModifiedDateTime": "0001-01-01T08:00:00Z",
"name": "internalblogs",
"webUrl": "https://xyz.sharepoint.com/internalblogs",
"displayName": "Internal blog"
},
{
...
}]
}