SharePoint REST API-创建现代网站集



我正在尝试使用SharePoint REST API在SharePoint Online中创建现代SharePoint网站集。

我正在使用_api/SPSiteManager/createAPI来创建新站点。

我已经使用App Only model创建了一个具有适当权限的应用程序,我可以获得一个令牌。但是,当我使用令牌进行POST调用时,我会得到以下错误。

<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-2147024891, System.UnauthorizedAccessException</m:code>
<m:message xml:lang="en-US">Access is denied. (Exception from HRESULT: 
0x80070005 (E_ACCESSDENIED))</m:message>
</m:error>

我在帖子中使用的身体如下:

{"request": { 
"Title": "Communication Site 1",
"Url":"https://[mytenancy].sharepoint.com/sites/commsite1",
"Lcid": 1033,
"ShareByEmailEnabled":false,
"Description":"Description",
"WebTemplate":"SITEPAGEPUBLISHING#0",
"SiteDesignId":"6142d2a0-63a5-4ba0-aede-d9fefca2c767",
"Owner":"[accountid]@[mytenancy].onmicrosoft.com",
"WebTemplateExtensionId":"00000000-0000-0000-0000-000000000000"
}}

应用程序已被授予以下权限

<AppPermissionRequests AllowAppOnlyPolicy="true"> 
<AppPermissionRequest Scope="http://sharepoint/content/tenant" 
Right="FullControl" />
</AppPermissionRequests>

这几乎是一篇标准的帖子,使用了我能找到的尽可能多的文档。

非常感谢任何想法。

感谢

请检查您是否在管理中心注册了共享点应用程序,如以下

https://contoso-admin.sharepoint.com/_layouts/15/appinv.aspx

我可以使用以下rest api通过应用创建网站

url: /_api/SPSiteManager/create
accept: application/json;odata.metadata=none
Content-Type: application/json;odata=verbose
method: POST
Body: 
{
"request": {
"Title": "xiexinCommunication Site 2",
"Url":"https://xxx.sharepoint.com/sites/xiexincommsite2",
"Lcid": 1033,
"ShareByEmailEnabled":false,
"Classification":"Low Business Impact",
"Description":"Description",
"WebTemplate":"SITEPAGEPUBLISHING#0",
"SiteDesignId":"6142d2a0-63a5-4ba0-aede-d9fefca2c767",
"Owner":"xxx@xxx.onmicrosoft.com",
"WebTemplateExtensionId":"00000000-0000-0000-0000-000000000000"}
}

最新更新