【问题标题】:SharePoint REST API - create Modern Site CollectionsSharePoint REST API - 创建新式网站集
【发布时间】:2022-11-10 03:27:59
【问题描述】:

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

我正在使用_api/SPSiteManager/create API 创建新站点。

我已经使用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>

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

任何想法都非常感谢。

谢谢

【问题讨论】:

  • 由于仅应用程序模型基本上在网站集上添加了应用程序上下文,您能否与我们分享您在哪个网站集上创建了应用程序注册?

标签: rest sharepoint-online


【解决方案1】:

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

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"}
    }

【讨论】:

    【解决方案2】:

    你能解决问题吗?我遇到了同样的错误。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多