Skip to main content

Modern SharePoint site creation with REST API.

The following REST commands are available for creating a modern SharePoint Communication site:
  • Create. Create a new SharePoint site.
  • Delete. Deletes a SharePoint site.
  • Status. Get the status of a SharePoint site.
The base URL for the REST commands is _api/SPSiteManager.

Create a modern site

Using the following REST api you can create both Communication sites and non-group associated Team Sites.
To specify which type of site to create you use the WebTemplate attribute. Use one of the following templates to select which type of site to create:
  • Communication Site: SITEPAGEPUBLISHING#0
  • non-group associated Team Site: STS#3

JSON


url: /_api/SPSiteManager/create
accept: application/json;odata.metadata=none
odata-version: 4.0
method: POST
body:
{
  "Title": "Communication Site 1",
  "Url":"https://contoso.sharepoint.com/sites/commsite1",
  "Lcid": 1033,
  "ShareByEmailEnabled":false,
  "Classification":"Low Business Impact",
  "Description":"Description",
  "WebTemplate":"SITEPAGEPUBLISHING#0",
  "SiteDesignId":"6142d2a0-63a5-4ba0-aede-d9fefca2c767",
  "Owner":"owner@yourtenant.onmicrosoft.com"
}

Response

If successful, this method returns a 200, OK response code and simple JSON object in the response body with the following details.
JSON
{
  "SiteId":"d11e59ca-1465-424c-be90-c847ba849af5",
  "SiteStatus":2,
  "SiteUrl":"https://contoso.sharepoint.com/sites/commsite1"
}

Delete a modern site

The REST API to delete a modern site is:
JSON
url: /_api/SPSiteManager/delete
method: POST
accept: application/json;odata.metadata=none
odata-version: 4.0
body:
{
  "siteId":"d11e59ca-1465-424c-be90-c847ba849af5"
}

Response

If successful this method returns a 200, OK response code.

Comments

  1. I have appeared in many IT certification exams but did not find any material like AZ-300 Dumps. It is the most reliable and concise exam material which gives a full understanding of the syllabus topics. Once I went through the dumps material I got a full view of the field and was able to solve all the questions in the final.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to get SPUser or SPGroup from Person or Group field

You have person or group field in SharePoint list and you want to programmatically get the user or person. The below code to gets SPUser from User or Group field in the list when multiple choice and Groups are not allowed in the field: //get SPUser SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["Users"].ToString()); SPUser user = userFieldValue.User; This part of code would help you to get SPUser when multiple choice is allowed and groups are not allowed: //Multiple choices are allowed SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString()); foreach (SPFieldUserValue userFieldValue in userFieldValueCollection) {     Console.WriteLine("     " + userFieldValue.User.LoginName); } And when group

SharePoint publishing page scheduling

In SharePoint 2010 publishing enabled team site collection is not showing schedule button in publish ribbon. Solution: Here is how to enable it  though the UI: Locate the SharePoint Server Web site on which you want to enable content approval and item scheduling. Click  Site Actions , click  Site Settings , and then click  Modify Pages Library Settings . Under  General Settings , click  Versioning Settings . Click  Yes  next to  Content Approval , and then click  OK . Click  Manage item scheduling .   Click to enable the  Enable scheduling of items in this list  check box, and then click  OK .

Changing Content Type Hub URL

Change the Hub URL through powershell by using: Set-SPMetadataServiceApplication -Identity " " -HubURI " " For Ex: Set-SPMetadataServiceApplication -Identity "Managed Metadata Service" -HubURI "http://contenttype.Domain.Com" When you try to do this you get this rather scary message: This is SharePoint telling you that this is a major thing so be careful! Essentially all your content types that you have published out will be removed if they can, and you have to republish all of your content types out again which can cause some issue.