Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Create a new newsLinkPage in the site pages list of a site.
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
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/{site-id}/pages
Request headers
Name | Description |
---|---|
Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
Content-Type | application/json for JSON content, including the required title property in multipart requests. Multipart requests use the multipart/form-data; boundary=your-boundary content type. Required. |
Prefer | include-unknown-enum-members. Use the Prefer: include-unknown-enum-members request header to get the following value in pageLayoutType, which is a evolvable enum: newsLink . |
Request body
In the request body, supply a JSON representation of the newsLinkPage object. The body must contain required properties placed directly in the request body; however, to set a banner image by uploading an image, it must be in a multipart message format as shown in the example. For the banner image upload, you must send a multipart request because it involves binary data.
Notes:
- To ensure successful parsing of the request body, the
@odata.type=#microsoft.graph.newsLinkPage
must be included in the request body.- Currently, to set the bannerImageWebUrl, the capability exists to upload the image bytes directly. These bytes get auto-saved in the site assets library, and the bannerImageWebUrl is then generated based on the persisted file. To achieve this, make a multipart request and set the
@microsoft.graph.bannerImageWebUrlContent
annotation to send the image content. For more details, see Example 2.
You can specify the following properties when you create a newsLinkPage.
Property | Type | Description |
---|---|---|
description | String | The descriptive text for the item. The maximum length limit is 250 characters. Optional. Inherited from baseSitePage. |
newsWebUrl | String | The URL of the news article referenced by the newsLinkPage. It can be an external link. Required. |
title | String | Title of the newsLinkPage. The maximum length limit is 110 characters. Required. Inherited from baseSitePage. |
Response
If successful, this method returns a 201 Created
response code and a newsLinkPage object in the response body.
Examples
Example 1: Create a news link page with only the required properties
The following example shows how to create a news link page using only the required properties.
Request
The following example shows a request.
POST /sites/c1370818-f5e0-4a40-a99b-be4520640642/pages
prefer: include-unknown-enum-members
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.newsLinkPage",
"newsWebUrl":"https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car",
"title": "Contoso Unveils First Self-Driving Car"
}
Response
The following example shows the response.
HTTP/1.1 201 Created
Content-type: application/json
{
"eTag": "\"{6A34958A-6F84-4571-A26E-B2CEB20261EB},3\"",
"id": "6a34958a-6f84-4571-a26e-b2ceb20261eb",
"lastModifiedDateTime": "2023-09-10T18:46:23Z",
"name": "contoso-unveils-first-self-driving-car.aspx",
"webUrl": "https://contoso.sharepoint.com/SitePages/contoso-unveils-first-self-driving-car.aspx",
"title": "Contoso Unveils First Self-Driving Car",
"pageLayout": "newsLink",
"newsWebUrl": "https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car",
"createdBy": {
"user": {
"displayName": "Jane Doe"
}
},
"lastModifiedBy": {
"user": {
"displayName": "Jane Doe"
}
},
"contentType": {
"id": "0x0101009D1CB255DA76424F860D91F20E6C4118002A50BFCFB7614729B56886FADA02339B000B27C676C81DC54289A1417148759BF3",
"name": "Repost Page"
},
"publishingState": {
"level":"checkout",
"versionId":"0.1",
"checkedOutBy": {
"user": {
"displayName":"Jane Doe",
"email":"JaneDoe@contoso.sharepoint.com"
}
}
}
}
Example 2: Create a news link page and upload the banner image file content
The following example shows how to create a news link page with a banner image. This process requires a multipart request.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/sites/c1370818-f5e0-4a40-a99b-be4520640642/pages
Prefer: include-unknown-enum-members
Content-type: multipart/form-data; boundary=MyPartBoundary198374
--MyPartBoundary198374
Content-Disposition: form-data; name="request"
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.newsLinkPage",
"title": "Microsoft Build brings AI tools to the forefront for developers",
"newsWebUrl": "https://someexternalnewssite.com/2024/05/23/microsoft-build-ai-tools-developers",
"description": "You only need two simple letters to accurately convey the major shift in the technology space this year: A and I. Beyond those letters, however, is a complex, evolving and exciting way in which we work, communicate and collaborate.",
"@microsoft.graph.bannerImageWebUrlContent": "name:content"
}
--MyPartBoundary198374
Content-Disposition: form-data; name="content"; filename="b3.jpg"
Content-Type: image/jpeg
... binary image data ...
--MyPartBoundary198374
Response
The following example shows the response. If a failure occurs when you upload or persist the banner image, the response contains @microsoft.graph.bannerImageWebUrlContentError
and a descriptive error message.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.newsLinkPage",
"createdDateTime": "2024-06-11T17:31:20Z",
"description": "You only need two simple letters to accurately convey the major shift in the technology space this year: A and I. Beyond those letters, however, is a complex, evolving and exciting way in which we work, communicate and collaborate.",
"eTag": "\"{179210C2-637E-4C61-8491-331D0D4A0C05},2\"",
"id": "179210c2-637e-4c61-8491-331d0d4a0c05",
"lastModifiedDateTime": "2024-06-11T17:31:21Z",
"name": "microsoft-build-ai-tools-developers.aspx",
"webUrl": "https://contoso.sharepoint.com/SitePages/Microsoft-Build-brings-AI-tools-to-the-forefront-for-developers.aspx",
"title": "Microsoft Build brings AI tools to the forefront for developers",
"pageLayout": "newsLink",
"bannerImageWebUrl": "https://contoso.sharepoint.com/_layouts/15/getpreview.ashx?path=/SiteAssets/SitePages/microsoft-build-ai-tools-developers/BannerImage.png",
"newsWebUrl": "https://someexternalnewssite.com/2024/05/23/microsoft-build-ai-tools-developers",
"createdBy": {
"user": {
"displayName": "John Doe",
"email": "jdoe@contoso.com"
}
},
"lastModifiedBy": {
"user": {
"displayName": "John Doe",
"email": "jdoe@contoso.com"
}
},
"publishingState": {
"level": "checkout",
"versionId": "0.1",
"checkedOutBy": {
"user": {
"displayName": "John Doe",
"email": "jdoe@contoso.com"
}
}
}
}