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"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new NewsLinkPage
{
OdataType = "#microsoft.graph.newsLinkPage",
NewsWebUrl = "https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car",
Title = "Contoso Unveils First Self-Driving Car",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites["{site-id}"].Pages.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("prefer", "include-unknown-enum-members");
});
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphsites "github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("prefer", "include-unknown-enum-members")
configuration := &graphsites.ItemPagesRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewBaseSitePage()
newsWebUrl := "https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car"
requestBody.SetNewsWebUrl(&newsWebUrl)
title := "Contoso Unveils First Self-Driving Car"
requestBody.SetTitle(&title)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
pages, err := graphClient.Sites().BySiteId("site-id").Pages().Post(context.Background(), requestBody, configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
NewsLinkPage baseSitePage = new NewsLinkPage();
baseSitePage.setOdataType("#microsoft.graph.newsLinkPage");
baseSitePage.setNewsWebUrl("https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car");
baseSitePage.setTitle("Contoso Unveils First Self-Driving Car");
BaseSitePage result = graphClient.sites().bySiteId("{site-id}").pages().post(baseSitePage, requestConfiguration -> {
requestConfiguration.headers.add("prefer", "include-unknown-enum-members");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.sites.item.pages.pages_request_builder import PagesRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.news_link_page import NewsLinkPage
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = NewsLinkPage(
odata_type = "#microsoft.graph.newsLinkPage",
news_web_url = "https://someexternalnewssite.com/2024/11/11/contoso-unveils-first-self-driving-car",
title = "Contoso Unveils First Self-Driving Car",
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("prefer", "include-unknown-enum-members")
result = await graph_client.sites.by_site_id('site-id').pages.post(request_body, request_configuration = request_configuration)
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
const options = {
authProvider,
};
const client = Client.init(options);
const baseSitePage = --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;
await client.api('/sites/c1370818-f5e0-4a40-a99b-be4520640642/pages')
.version('beta')
.post(baseSitePage);
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"
}
}
}
}