|
| 1 | +--- |
| 2 | +title: "Create newsLinkPage" |
| 3 | +description: "Create a new news link page in the site pages list of a site." |
| 4 | +author: "shgangan" |
| 5 | +ms.date: 04/01/2024 |
| 6 | +ms.localizationpriority: "medium" |
| 7 | +ms.subservice: "sharepoint" |
| 8 | +doc_type: "apiPageType" |
| 9 | +--- |
| 10 | + |
| 11 | +# Create newsLinkPage |
| 12 | + |
| 13 | +Namespace: microsoft.graph |
| 14 | + |
| 15 | +[!INCLUDE [beta-disclaimer](../../includes/beta-disclaimer.md)] |
| 16 | + |
| 17 | +Create a new [newsLinkPage](../resources/newslinkpage.md) in the site pages [list](../resources/list.md) of a [site](../resources/site.md). |
| 18 | + |
| 19 | +## Permissions |
| 20 | + |
| 21 | +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](/graph/permissions-overview#best-practices-for-using-microsoft-graph-permissions). For details about delegated and application permissions, see [Permission types](/graph/permissions-overview#permission-types). To learn more about these permissions, see the [permissions reference](/graph/permissions-reference). |
| 22 | + |
| 23 | +<!-- { "blockType": "permissions", "name": "newslinkpage_create" } --> |
| 24 | +[!INCLUDE [permissions-table](../includes/permissions/newslinkpage-create-permissions.md)] |
| 25 | + |
| 26 | +## HTTP request |
| 27 | + |
| 28 | +<!-- { |
| 29 | + "blockType": "ignored" |
| 30 | +} |
| 31 | +--> |
| 32 | +```http |
| 33 | +POST /sites/{site-id}/pages |
| 34 | +``` |
| 35 | + |
| 36 | +## Request headers |
| 37 | + |
| 38 | +|Name|Description| |
| 39 | +|:---|:---| |
| 40 | +|Authorization|Bearer {token}. Required. Learn more about [authentication and authorization](/graph/auth/auth-concepts).| |
| 41 | +|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. | |
| 42 | +|Prefer | include-unknown-enum-members. You must use the `Prefer: include-unknown-enum-members` request header to get the following value in [pageLayoutType](../resources/basesitepage.md#pagelayouttype-values), which is a [evolvable enum](/graph/best-practices-concept#handling-future-members-in-evolvable-enumerations): `newsLink`. | |
| 43 | + |
| 44 | +## Request body |
| 45 | + |
| 46 | +In the request body, supply a JSON representation of the [newsLinkPage](../resources/newslinkpage.md) 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. |
| 47 | + |
| 48 | +> **Notes:** |
| 49 | +> * To ensure successful parsing of the request body, the `@odata.type=#microsoft.graph.newsLinkPage` must be included in the request body. |
| 50 | +> * 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](../api/newslinkpage-create.md#example-2-create-a-news-link-page-and-upload-the-banner-image-file-content). |
| 51 | +
|
| 52 | +You can specify the following properties when you create a [newsLinkPage](../resources/newslinkpage.md). |
| 53 | + |
| 54 | +|Property|Type|Description| |
| 55 | +|:---|:---|:---| |
| 56 | +|description|String|The descriptive text for the item. The maximum length limit is 250 characters. Optional. Inherited from [baseSitePage](../resources/basesitepage.md).| |
| 57 | +|newsWebUrl|String|The URL of the news article referenced by the **newsLinkPage**. It can be an external link. Required.| |
| 58 | +|title|String|Title of the **newsLinkPage**. The maximum length limit is 110 characters. Required. Inherited from [baseSitePage](../resources/basesitepage.md).| |
| 59 | + |
| 60 | +## Response |
| 61 | + |
| 62 | +If successful, this method returns a `201 Created` response code and a [newsLinkPage](../resources/newslinkpage.md) object in the response body. |
| 63 | + |
| 64 | +## Examples |
| 65 | + |
| 66 | +### Example 1: Create a news link page with only the required properties |
| 67 | + |
| 68 | +The following example shows how to create a [news link page](../resources/newslinkpage.md) using only the required properties. |
| 69 | + |
| 70 | +#### Request |
| 71 | +The following example shows a request. |
| 72 | + |
| 73 | +<!-- { "blockType": "request", "name": "create-newslinkpage", "scopes": "sites.readwrite.all" } --> |
| 74 | +``` |
| 75 | +POST /sites/c1370818-f5e0-4a40-a99b-be4520640642/pages |
| 76 | +prefer: include-unknown-enum-members |
| 77 | +Content-Type: application/json |
| 78 | +
|
| 79 | +{ |
| 80 | + "@odata.type": "#microsoft.graph.newsLinkPage", |
| 81 | + "newsWebUrl":"https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car", |
| 82 | + "title": "Contoso Unveils First Self-Driving Car" |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +#### Response |
| 87 | + |
| 88 | +The following example shows the response. |
| 89 | + |
| 90 | +<!-- { |
| 91 | + "blockType": "response", |
| 92 | + "truncated": true, |
| 93 | + "@odata.type": "microsoft.graph.newsLinkPage" |
| 94 | +} |
| 95 | +--> |
| 96 | +```http |
| 97 | +HTTP/1.1 201 Created |
| 98 | +Content-type: application/json |
| 99 | +
|
| 100 | +{ |
| 101 | + "eTag": "\"{6A34958A-6F84-4571-A26E-B2CEB20261EB},3\"", |
| 102 | + "id": "6a34958a-6f84-4571-a26e-b2ceb20261eb", |
| 103 | + "lastModifiedDateTime": "2023-09-10T18:46:23Z", |
| 104 | + "name": "contoso-unveils-first-self-driving-car.aspx", |
| 105 | + "webUrl": "https://contoso.sharepoint.com/SitePages/contoso-unveils-first-self-driving-car.aspx", |
| 106 | + "title": "Contoso Unveils First Self-Driving Car", |
| 107 | + "pageLayout": "newsLink", |
| 108 | + "newsWebUrl": "https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car", |
| 109 | + "createdBy": { |
| 110 | + "user": { |
| 111 | + "displayName": "Jane Doe" |
| 112 | + } |
| 113 | + }, |
| 114 | + "lastModifiedBy": { |
| 115 | + "user": { |
| 116 | + "displayName": "Jane Doe" |
| 117 | + } |
| 118 | + }, |
| 119 | + "contentType": { |
| 120 | + "id": "0x0101009D1CB255DA76424F860D91F20E6C4118002A50BFCFB7614729B56886FADA02339B000B27C676C81DC54289A1417148759BF3", |
| 121 | + "name": "Repost Page" |
| 122 | + }, |
| 123 | + "publishingState": { |
| 124 | + "level":"checkout", |
| 125 | + "versionId":"0.1", |
| 126 | + "checkedOutBy": { |
| 127 | + "user": { |
| 128 | + "displayName":"Jane Doe", |
| 129 | + "email":"JaneDoe@contoso.sharepoint.com" |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +### Example 2: Create a news link page and upload the banner image file content |
| 137 | + |
| 138 | +The following example shows how to create a [news link page](../resources/newslinkpage.md) with a banner image. This process requires a multipart request. |
| 139 | + |
| 140 | +#### Request |
| 141 | + |
| 142 | +The following example shows a request. |
| 143 | + |
| 144 | +<!-- { |
| 145 | + "blockType": "request", |
| 146 | + "name": "create-newslinkpage-multipart", |
| 147 | + "scopes": "sites.readwrite.all" |
| 148 | +} --> |
| 149 | +```http |
| 150 | +POST https://graph.microsoft.com/beta/sites/c1370818-f5e0-4a40-a99b-be4520640642/pages |
| 151 | +Prefer: include-unknown-enum-members |
| 152 | +Content-type: multipart/form-data; boundary=MyPartBoundary198374 |
| 153 | +
|
| 154 | +--MyPartBoundary198374 |
| 155 | +Content-Disposition: form-data; name="request" |
| 156 | +Content-Type: application/json |
| 157 | +
|
| 158 | +{ |
| 159 | + "@odata.type": "#microsoft.graph.newsLinkPage", |
| 160 | + "title": "Microsoft Build brings AI tools to the forefront for developers", |
| 161 | + "newsWebUrl": "https://someexternalnewssite.com/2024/05/23/microsoft-build-ai-tools-developers", |
| 162 | + "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.", |
| 163 | + "@microsoft.graph.bannerImageWebUrlContent": "name:content" |
| 164 | +} |
| 165 | +
|
| 166 | +--MyPartBoundary198374 |
| 167 | +Content-Disposition: form-data; name="content"; filename="b3.jpg" |
| 168 | +Content-Type: image/jpeg |
| 169 | +
|
| 170 | +... binary image data ... |
| 171 | +
|
| 172 | +--MyPartBoundary198374 |
| 173 | +``` |
| 174 | + |
| 175 | +#### Response |
| 176 | + |
| 177 | +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. |
| 178 | + |
| 179 | +>**Note:** The response object shown here might be shortened for readability. |
| 180 | +
|
| 181 | +<!-- { |
| 182 | + "blockType": "response", |
| 183 | + "truncated": true, |
| 184 | + "@odata.type": "microsoft.graph.newsLinkPage" |
| 185 | +} |
| 186 | +--> |
| 187 | +```http |
| 188 | +HTTP/1.1 201 Created |
| 189 | +Content-Type: application/json |
| 190 | +
|
| 191 | +{ |
| 192 | + "@odata.type": "#microsoft.graph.newsLinkPage", |
| 193 | + "createdDateTime": "2024-06-11T17:31:20Z", |
| 194 | + "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.", |
| 195 | + "eTag": "\"{179210C2-637E-4C61-8491-331D0D4A0C05},2\"", |
| 196 | + "id": "179210c2-637e-4c61-8491-331d0d4a0c05", |
| 197 | + "lastModifiedDateTime": "2024-06-11T17:31:21Z", |
| 198 | + "name": "microsoft-build-ai-tools-developers.aspx", |
| 199 | + "webUrl": "https://contoso.sharepoint.com/SitePages/Microsoft-Build-brings-AI-tools-to-the-forefront-for-developers.aspx", |
| 200 | + "title": "Microsoft Build brings AI tools to the forefront for developers", |
| 201 | + "pageLayout": "newsLink", |
| 202 | + "bannerImageWebUrl": "https://contoso.sharepoint.com/_layouts/15/getpreview.ashx?path=/SiteAssets/SitePages/microsoft-build-ai-tools-developers/BannerImage.png", |
| 203 | + "newsWebUrl": "https://someexternalnewssite.com/2024/05/23/microsoft-build-ai-tools-developers", |
| 204 | + "createdBy": { |
| 205 | + "user": { |
| 206 | + "displayName": "John Doe", |
| 207 | + "email": "jdoe@contoso.com" |
| 208 | + } |
| 209 | + }, |
| 210 | + "lastModifiedBy": { |
| 211 | + "user": { |
| 212 | + "displayName": "John Doe", |
| 213 | + "email": "jdoe@contoso.com" |
| 214 | + } |
| 215 | + }, |
| 216 | + "publishingState": { |
| 217 | + "level": "checkout", |
| 218 | + "versionId": "0.1", |
| 219 | + "checkedOutBy": { |
| 220 | + "user": { |
| 221 | + "displayName": "John Doe", |
| 222 | + "email": "jdoe@contoso.com" |
| 223 | + } |
| 224 | + } |
| 225 | + } |
| 226 | +} |
| 227 | +``` |
| 228 | + |
| 229 | +<!-- |
| 230 | +{ |
| 231 | + "type": "#page.annotation", |
| 232 | + "description": "Create newsLinkPage", |
| 233 | + "keywords": "", |
| 234 | + "section": "documentation", |
| 235 | + "tocPath": "", |
| 236 | + "suppressions": [ |
| 237 | + "Error: /api/newslinkpage-create.md/create-newslinkpage: |
| 238 | + Error parsing resource definition: Unexpected character encountered while parsing number: M. Path '', line 1, position 2.", |
| 239 | + "Error: /api/newslinkpage-create.md/create-newslinkpage-multipart: |
| 240 | + Error parsing resource definition: Unexpected character encountered while parsing number: M. Path '', line 1, position 2.", |
| 241 | + "Error: /api/newslinkpage-create.md/create-newslinkpage: |
| 242 | + Error parsing resource definition: Unexpected character encountered while parsing number: M. Path '', line 1, position 2." |
| 243 | + ] |
| 244 | +} |
| 245 | +--> |
0 commit comments