Muokkaa

Jaa


sitePage: saveAsTemplate

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Save a sitePage as a pageTemplate in a site.

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Sites.ReadWrite.All Not available.
Delegated (personal Microsoft account) Not supported. Not supported.
Application Sites.ReadWrite.All Not available.

HTTP request

POST /sites/{siteId}/pages/{pageId}/microsoft.graph.sitePage/saveAsTemplate

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.

Request body

In the request body, supply a JSON representation of the saveAsTemplate to use in the request payload.

Response

If successful, this method returns a 201 Created HTTP response and the created pageTemplate object.

Example

The following example shows how to save a site page as a template page.

Request

POST /sites/dd00d52e-0db7-4d5f-8269-90060ac688d1/pages/f6ed8c43-9923-4c6c-ba09-9c32b8f10aeb/microsoft.graph.sitePage/saveAsTemplate
Content-Type: application/json

{
  "title": "SampleTitle",
  "name": "SampleTemplate.aspx"
}

Response

The following example shows the response.

Note: The response object might be shortened for readability.

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.type": "microsoft.graph.pageTemplate",
    "id": "0dd6ddd6-45bd-4acd-b683-de0e6e726371",
    "name": "SampleTemplate.aspx",
    "webUrl": "https://contoso.sharepoint.com/SitePages/Templates/Sample.aspx",
    "title": "SampleTitle",
    "pageLayout": "article",
    "createdBy": {
      "user": {
          "displayName": "Rahul Mittal",
          "email": "rahmit@contoso.com"
      }
    },
    "lastModifiedBy": {
      "user": {
          "displayName": "Rahul Mittal",
          "email": "rahmit@contoso.com"
      }
    },
    "publishingState": {
      "level": "checkout",
      "versionId": "0.1",
      "checkedOutBy": {
        "user": {
          "displayName": "Rahul Mittal",
          "email": "rahmit@contoso.com"
        }
      }
    },
    "titleArea": {
        "enableGradientEffect": true,
        "imageWebUrl": "https://cdn.contoso.osi.office.net/m365content/publish/005292d6-9dcc-4fc5-b50b-b2d0383a411b/image.jpg",
        "layout": "colorBlock",
        "showAuthor": true,
        "showPublishedDate": false,
        "showTextBlockAboveTitle": false,
        "textAboveTitle": "TEXT ABOVE TITLE",
        "textAlignment": "left",
        "imageSourceType": 2
    }
}