Oct 16 2022 12:56 AM
I'm trying to use the SharePoint REST API's to create a modern SharePoint site collection in SharePoint Online.
I'm using the _api/SPSiteManager/create API to create the new site.
I have used the App Only model to create an app with the approprate permissons I can obtain a token but when I make the POST call with the token I get the following error.
<?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>
The body that I'm using with the post is
{
"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"
}}
The App has been granted the following permissions
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest
Scope="http://sharepoint/content/tenant"
Right="FullControl" />
</AppPermissionRequests>
It's pretty much a standard post using as much of the documentation as I can find.
Any ideas greatly appreciated.
Thanks