L’exemple suivant montre comment créer une page.
POST /sites/{site-id}/pages
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.sitePage",
"name": "test.aspx",
"title": "test",
"pageLayout": "article",
"showComments": true,
"showRecommendedPages": false,
"titleArea": {
"enableGradientEffect": true,
"imageWebUrl": "https://cdn.hubblecontent.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,
"title": "sample1"
},
"canvasLayout": {
"horizontalSections": [
{
"layout": "oneThirdRightColumn",
"id": "1",
"emphasis": "none",
"columns": [
{
"id": "1",
"width": 8,
"webparts": [
{
"id": "6f9230af-2a98-4952-b205-9ede4f9ef548",
"innerHtml": "<p><b>Hello!</b></p>"
}
]
},
{
"id": "2",
"width": 4,
"webparts": [
{
"id": "73d07dde-3474-4545-badb-f28ba239e0e1",
"webPartType": "d1d91016-032f-456d-98a4-721247c305e8",
"data": {
"dataVersion": "1.9",
"description": "Show an image on your page",
"title": "Image",
"properties": {
"imageSourceType": 2,
"altText": "",
"overlayText": "",
"siteid": "0264cabe-6b92-450a-b162-b0c3d54fe5e8",
"webid": "f3989670-cd37-4514-8ccb-0f7c2cbe5314",
"listid": "bdb41041-eb06-474e-ac29-87093386bb14",
"uniqueid": "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb",
"imgWidth": 4288,
"imgHeight": 2848,
"fixAspectRatio": false,
"captionText": "",
"alignment": "Center"
},
"serverProcessedContent": {
"imageSources": [
{
"key": "imageSource",
"value": "/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG"
}
],
"customMetadata": [
{
"key": "imageSource",
"value": {
"siteid": "0264cabe-6b92-450a-b162-b0c3d54fe5e8",
"webid": "f3989670-cd37-4514-8ccb-0f7c2cbe5314",
"listid": "bdb41041-eb06-474e-ac29-87093386bb14",
"uniqueid": "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb",
"width": "4288",
"height": "2848"
}
}
]
}
}
}
]
}
]
}
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new SitePage
{
OdataType = "#microsoft.graph.sitePage",
Name = "test.aspx",
Title = "test",
PageLayout = PageLayoutType.Article,
ShowComments = true,
ShowRecommendedPages = false,
TitleArea = new TitleArea
{
EnableGradientEffect = true,
ImageWebUrl = "https://cdn.hubblecontent.osi.office.net/m365content/publish/005292d6-9dcc-4fc5-b50b-b2d0383a411b/image.jpg",
Layout = TitleAreaLayoutType.ColorBlock,
ShowAuthor = true,
ShowPublishedDate = false,
ShowTextBlockAboveTitle = false,
TextAboveTitle = "TEXT ABOVE TITLE",
TextAlignment = TitleAreaTextAlignmentType.Left,
AdditionalData = new Dictionary<string, object>
{
{
"imageSourceType" , 2
},
{
"title" , "sample1"
},
},
},
CanvasLayout = new CanvasLayout
{
HorizontalSections = new List<HorizontalSection>
{
new HorizontalSection
{
Layout = HorizontalSectionLayoutType.OneThirdRightColumn,
Id = "1",
Emphasis = SectionEmphasisType.None,
Columns = new List<HorizontalSectionColumn>
{
new HorizontalSectionColumn
{
Id = "1",
Width = 8,
Webparts = new List<WebPart>
{
new WebPart
{
Id = "6f9230af-2a98-4952-b205-9ede4f9ef548",
AdditionalData = new Dictionary<string, object>
{
{
"innerHtml" , "<p><b>Hello!</b></p>"
},
},
},
},
},
new HorizontalSectionColumn
{
Id = "2",
Width = 4,
Webparts = new List<WebPart>
{
new WebPart
{
Id = "73d07dde-3474-4545-badb-f28ba239e0e1",
AdditionalData = new Dictionary<string, object>
{
{
"webPartType" , "d1d91016-032f-456d-98a4-721247c305e8"
},
{
"data" , new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"dataVersion", new UntypedString("1.9")
},
{
"description", new UntypedString("Show an image on your page")
},
{
"title", new UntypedString("Image")
},
{
"properties", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"imageSourceType", new UntypedString("2")
},
{
"altText", new UntypedString("")
},
{
"overlayText", new UntypedString("")
},
{
"siteid", new UntypedString("0264cabe-6b92-450a-b162-b0c3d54fe5e8")
},
{
"webid", new UntypedString("f3989670-cd37-4514-8ccb-0f7c2cbe5314")
},
{
"listid", new UntypedString("bdb41041-eb06-474e-ac29-87093386bb14")
},
{
"uniqueid", new UntypedString("d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb")
},
{
"imgWidth", new UntypedString("4288")
},
{
"imgHeight", new UntypedString("2848")
},
{
"fixAspectRatio", new UntypedBoolean(false)
},
{
"captionText", new UntypedString("")
},
{
"alignment", new UntypedString("Center")
},
})
},
{
"serverProcessedContent", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"imageSources", new UntypedArray(new List<UntypedNode>
{
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"key", new UntypedString("imageSource")
},
{
"value", new UntypedString("/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG")
},
}),
})
},
{
"customMetadata", new UntypedArray(new List<UntypedNode>
{
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"key", new UntypedString("imageSource")
},
{
"value", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"siteid", new UntypedString("0264cabe-6b92-450a-b162-b0c3d54fe5e8")
},
{
"webid", new UntypedString("f3989670-cd37-4514-8ccb-0f7c2cbe5314")
},
{
"listid", new UntypedString("bdb41041-eb06-474e-ac29-87093386bb14")
},
{
"uniqueid", new UntypedString("d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb")
},
{
"width", new UntypedString("4288")
},
{
"height", new UntypedString("2848")
},
})
},
}),
})
},
})
},
})
},
},
},
},
},
},
},
},
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites["{site-id}"].Pages.PostAsync(requestBody);
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).
mgc sites pages create --site-id {site-id} --body '{\
"@odata.type": "#microsoft.graph.sitePage",\
"name": "test.aspx",\
"title": "test",\
"pageLayout": "article",\
"showComments": true,\
"showRecommendedPages": false,\
"titleArea": {\
"enableGradientEffect": true,\
"imageWebUrl": "https://cdn.hubblecontent.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,\
"title": "sample1"\
},\
"canvasLayout": {\
"horizontalSections": [\
{\
"layout": "oneThirdRightColumn",\
"id": "1",\
"emphasis": "none",\
"columns": [\
{\
"id": "1",\
"width": 8,\
"webparts": [\
{\
"id": "6f9230af-2a98-4952-b205-9ede4f9ef548",\
"innerHtml": "<p><b>Hello!</b></p>"\
}\
]\
},\
{\
"id": "2",\
"width": 4,\
"webparts": [\
{\
"id": "73d07dde-3474-4545-badb-f28ba239e0e1",\
"webPartType": "d1d91016-032f-456d-98a4-721247c305e8",\
"data": {\
"dataVersion": "1.9",\
"description": "Show an image on your page",\
"title": "Image",\
"properties": {\
"imageSourceType": 2,\
"altText": "",\
"overlayText": "",\
"siteid": "0264cabe-6b92-450a-b162-b0c3d54fe5e8",\
"webid": "f3989670-cd37-4514-8ccb-0f7c2cbe5314",\
"listid": "bdb41041-eb06-474e-ac29-87093386bb14",\
"uniqueid": "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb",\
"imgWidth": 4288,\
"imgHeight": 2848,\
"fixAspectRatio": false,\
"captionText": "",\
"alignment": "Center"\
},\
"serverProcessedContent": {\
"imageSources": [\
{\
"key": "imageSource",\
"value": "/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG"\
}\
],\
"customMetadata": [\
{\
"key": "imageSource",\
"value": {\
"siteid": "0264cabe-6b92-450a-b162-b0c3d54fe5e8",\
"webid": "f3989670-cd37-4514-8ccb-0f7c2cbe5314",\
"listid": "bdb41041-eb06-474e-ac29-87093386bb14",\
"uniqueid": "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb",\
"width": "4288",\
"height": "2848"\
}\
}\
]\
}\
}\
}\
]\
}\
]\
}\
]\
}\
}\
'
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SitePage baseSitePage = new SitePage();
baseSitePage.setOdataType("#microsoft.graph.sitePage");
baseSitePage.setName("test.aspx");
baseSitePage.setTitle("test");
baseSitePage.setPageLayout(PageLayoutType.Article);
baseSitePage.setShowComments(true);
baseSitePage.setShowRecommendedPages(false);
TitleArea titleArea = new TitleArea();
titleArea.setEnableGradientEffect(true);
titleArea.setImageWebUrl("https://cdn.hubblecontent.osi.office.net/m365content/publish/005292d6-9dcc-4fc5-b50b-b2d0383a411b/image.jpg");
titleArea.setLayout(TitleAreaLayoutType.ColorBlock);
titleArea.setShowAuthor(true);
titleArea.setShowPublishedDate(false);
titleArea.setShowTextBlockAboveTitle(false);
titleArea.setTextAboveTitle("TEXT ABOVE TITLE");
titleArea.setTextAlignment(TitleAreaTextAlignmentType.Left);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("imageSourceType", 2);
additionalData.put("title", "sample1");
titleArea.setAdditionalData(additionalData);
baseSitePage.setTitleArea(titleArea);
CanvasLayout canvasLayout = new CanvasLayout();
LinkedList<HorizontalSection> horizontalSections = new LinkedList<HorizontalSection>();
HorizontalSection horizontalSection = new HorizontalSection();
horizontalSection.setLayout(HorizontalSectionLayoutType.OneThirdRightColumn);
horizontalSection.setId("1");
horizontalSection.setEmphasis(SectionEmphasisType.None);
LinkedList<HorizontalSectionColumn> columns = new LinkedList<HorizontalSectionColumn>();
HorizontalSectionColumn horizontalSectionColumn = new HorizontalSectionColumn();
horizontalSectionColumn.setId("1");
horizontalSectionColumn.setWidth(8);
LinkedList<WebPart> webparts = new LinkedList<WebPart>();
WebPart webPart = new WebPart();
webPart.setId("6f9230af-2a98-4952-b205-9ede4f9ef548");
HashMap<String, Object> additionalData1 = new HashMap<String, Object>();
additionalData1.put("innerHtml", "<p><b>Hello!</b></p>");
webPart.setAdditionalData(additionalData1);
webparts.add(webPart);
horizontalSectionColumn.setWebparts(webparts);
columns.add(horizontalSectionColumn);
HorizontalSectionColumn horizontalSectionColumn1 = new HorizontalSectionColumn();
horizontalSectionColumn1.setId("2");
horizontalSectionColumn1.setWidth(4);
LinkedList<WebPart> webparts1 = new LinkedList<WebPart>();
WebPart webPart1 = new WebPart();
webPart1.setId("73d07dde-3474-4545-badb-f28ba239e0e1");
HashMap<String, Object> additionalData2 = new HashMap<String, Object>();
additionalData2.put("webPartType", "d1d91016-032f-456d-98a4-721247c305e8");
data = new ();
data.setDataVersion("1.9");
data.setDescription("Show an image on your page");
data.setTitle("Image");
properties = new ();
properties.setImageSourceType(2);
properties.setAltText("");
properties.setOverlayText("");
properties.setSiteid("0264cabe-6b92-450a-b162-b0c3d54fe5e8");
properties.setWebid("f3989670-cd37-4514-8ccb-0f7c2cbe5314");
properties.setListid("bdb41041-eb06-474e-ac29-87093386bb14");
properties.setUniqueid("d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb");
properties.setImgWidth(4288);
properties.setImgHeight(2848);
properties.setFixAspectRatio(false);
properties.setCaptionText("");
properties.setAlignment("Center");
data.setProperties(properties);
serverProcessedContent = new ();
LinkedList<Object> imageSources = new LinkedList<Object>();
property = new ();
property.setKey("imageSource");
property.setValue("/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG");
imageSources.add(property);
serverProcessedContent.setImageSources(imageSources);
LinkedList<Object> customMetadata = new LinkedList<Object>();
property1 = new ();
property1.setKey("imageSource");
value1 = new ();
value1.setSiteid("0264cabe-6b92-450a-b162-b0c3d54fe5e8");
value1.setWebid("f3989670-cd37-4514-8ccb-0f7c2cbe5314");
value1.setListid("bdb41041-eb06-474e-ac29-87093386bb14");
value1.setUniqueid("d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb");
value1.setWidth("4288");
value1.setHeight("2848");
property1.setValue(value1);
customMetadata.add(property1);
serverProcessedContent.setCustomMetadata(customMetadata);
data.setServerProcessedContent(serverProcessedContent);
additionalData2.put("data", data);
webPart1.setAdditionalData(additionalData2);
webparts1.add(webPart1);
horizontalSectionColumn1.setWebparts(webparts1);
columns.add(horizontalSectionColumn1);
horizontalSection.setColumns(columns);
horizontalSections.add(horizontalSection);
canvasLayout.setHorizontalSections(horizontalSections);
baseSitePage.setCanvasLayout(canvasLayout);
BaseSitePage result = graphClient.sites().bySiteId("{site-id}").pages().post(baseSitePage);
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).
const options = {
authProvider,
};
const client = Client.init(options);
const baseSitePage = {
'@odata.type': '#microsoft.graph.sitePage',
name: 'test.aspx',
title: 'test',
pageLayout: 'article',
showComments: true,
showRecommendedPages: false,
titleArea: {
enableGradientEffect: true,
imageWebUrl: 'https://cdn.hubblecontent.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,
title: 'sample1'
},
canvasLayout: {
horizontalSections: [
{
layout: 'oneThirdRightColumn',
id: '1',
emphasis: 'none',
columns: [
{
id: '1',
width: 8,
webparts: [
{
id: '6f9230af-2a98-4952-b205-9ede4f9ef548',
innerHtml: '<p><b>Hello!</b></p>'
}
]
},
{
id: '2',
width: 4,
webparts: [
{
id: '73d07dde-3474-4545-badb-f28ba239e0e1',
webPartType: 'd1d91016-032f-456d-98a4-721247c305e8',
data: {
dataVersion: '1.9',
description: 'Show an image on your page',
title: 'Image',
properties: {
imageSourceType: 2,
altText: '',
overlayText: '',
siteid: '0264cabe-6b92-450a-b162-b0c3d54fe5e8',
webid: 'f3989670-cd37-4514-8ccb-0f7c2cbe5314',
listid: 'bdb41041-eb06-474e-ac29-87093386bb14',
uniqueid: 'd9f94b40-78ba-48d0-a39f-3cb23c2fe7eb',
imgWidth: 4288,
imgHeight: 2848,
fixAspectRatio: false,
captionText: '',
alignment: 'Center'
},
serverProcessedContent: {
imageSources: [
{
key: 'imageSource',
value: '/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG'
}
],
customMetadata: [
{
key: 'imageSource',
value: {
siteid: '0264cabe-6b92-450a-b162-b0c3d54fe5e8',
webid: 'f3989670-cd37-4514-8ccb-0f7c2cbe5314',
listid: 'bdb41041-eb06-474e-ac29-87093386bb14',
uniqueid: 'd9f94b40-78ba-48d0-a39f-3cb23c2fe7eb',
width: '4288',
height: '2848'
}
}
]
}
}
}
]
}
]
}
]
}
};
await client.api('/sites/{site-id}/pages')
.post(baseSitePage);
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\SitePage;
use Microsoft\Graph\Generated\Models\PageLayoutType;
use Microsoft\Graph\Generated\Models\TitleArea;
use Microsoft\Graph\Generated\Models\TitleAreaLayoutType;
use Microsoft\Graph\Generated\Models\TitleAreaTextAlignmentType;
use Microsoft\Graph\Generated\Models\CanvasLayout;
use Microsoft\Graph\Generated\Models\HorizontalSection;
use Microsoft\Graph\Generated\Models\HorizontalSectionLayoutType;
use Microsoft\Graph\Generated\Models\SectionEmphasisType;
use Microsoft\Graph\Generated\Models\HorizontalSectionColumn;
use Microsoft\Graph\Generated\Models\WebPart;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SitePage();
$requestBody->setOdataType('#microsoft.graph.sitePage');
$requestBody->setName('test.aspx');
$requestBody->setTitle('test');
$requestBody->setPageLayout(new PageLayoutType('article'));
$requestBody->setShowComments(true);
$requestBody->setShowRecommendedPages(false);
$titleArea = new TitleArea();
$titleArea->setEnableGradientEffect(true);
$titleArea->setImageWebUrl('https://cdn.hubblecontent.osi.office.net/m365content/publish/005292d6-9dcc-4fc5-b50b-b2d0383a411b/image.jpg');
$titleArea->setLayout(new TitleAreaLayoutType('colorBlock'));
$titleArea->setShowAuthor(true);
$titleArea->setShowPublishedDate(false);
$titleArea->setShowTextBlockAboveTitle(false);
$titleArea->setTextAboveTitle('TEXT ABOVE TITLE');
$titleArea->setTextAlignment(new TitleAreaTextAlignmentType('left'));
$additionalData = [
'imageSourceType' => 2,
'title' => 'sample1',
];
$titleArea->setAdditionalData($additionalData);
$requestBody->setTitleArea($titleArea);
$canvasLayout = new CanvasLayout();
$horizontalSectionsHorizontalSection1 = new HorizontalSection();
$horizontalSectionsHorizontalSection1->setLayout(new HorizontalSectionLayoutType('oneThirdRightColumn'));
$horizontalSectionsHorizontalSection1->setId('1');
$horizontalSectionsHorizontalSection1->setEmphasis(new SectionEmphasisType('none'));
$columnsHorizontalSectionColumn1 = new HorizontalSectionColumn();
$columnsHorizontalSectionColumn1->setId('1');
$columnsHorizontalSectionColumn1->setWidth(8);
$webpartsWebPart1 = new WebPart();
$webpartsWebPart1->setId('6f9230af-2a98-4952-b205-9ede4f9ef548');
$additionalData = [
'innerHtml' => '<p><b>Hello!</b></p>',
];
$webpartsWebPart1->setAdditionalData($additionalData);
$webpartsArray []= $webpartsWebPart1;
$columnsHorizontalSectionColumn1->setWebparts($webpartsArray);
$columnsArray []= $columnsHorizontalSectionColumn1;
$columnsHorizontalSectionColumn2 = new HorizontalSectionColumn();
$columnsHorizontalSectionColumn2->setId('2');
$columnsHorizontalSectionColumn2->setWidth(4);
$webpartsWebPart1 = new WebPart();
$webpartsWebPart1->setId('73d07dde-3474-4545-badb-f28ba239e0e1');
$additionalData = [
'webPartType' => 'd1d91016-032f-456d-98a4-721247c305e8',
'data' => [
'dataVersion' => '1.9',
'description' => 'Show an image on your page',
'title' => 'Image',
'properties' => [
'imageSourceType' => 2,
'altText' => '',
'overlayText' => '',
'siteid' => '0264cabe-6b92-450a-b162-b0c3d54fe5e8',
'webid' => 'f3989670-cd37-4514-8ccb-0f7c2cbe5314',
'listid' => 'bdb41041-eb06-474e-ac29-87093386bb14',
'uniqueid' => 'd9f94b40-78ba-48d0-a39f-3cb23c2fe7eb',
'imgWidth' => 4288,
'imgHeight' => 2848,
'fixAspectRatio' => false,
'captionText' => '',
'alignment' => 'Center',
],
'serverProcessedContent' => [
'imageSources' => [
[
'key' => 'imageSource',
'value' => '/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG',
],
],
'customMetadata' => [
[
'key' => 'imageSource',
'value' => [
'siteid' => '0264cabe-6b92-450a-b162-b0c3d54fe5e8',
'webid' => 'f3989670-cd37-4514-8ccb-0f7c2cbe5314',
'listid' => 'bdb41041-eb06-474e-ac29-87093386bb14',
'uniqueid' => 'd9f94b40-78ba-48d0-a39f-3cb23c2fe7eb',
'width' => '4288',
'height' => '2848',
],
],
],
],
],
];
$webpartsWebPart1->setAdditionalData($additionalData);
$webpartsArray []= $webpartsWebPart1;
$columnsHorizontalSectionColumn2->setWebparts($webpartsArray);
$columnsArray []= $columnsHorizontalSectionColumn2;
$horizontalSectionsHorizontalSection1->setColumns($columnsArray);
$horizontalSectionsArray []= $horizontalSectionsHorizontalSection1;
$canvasLayout->setHorizontalSections($horizontalSectionsArray);
$requestBody->setCanvasLayout($canvasLayout);
$result = $graphServiceClient->sites()->bySiteId('site-id')->pages()->post($requestBody)->wait();
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).
Import-Module Microsoft.Graph.Sites
$params = @{
"@odata.type" = "#microsoft.graph.sitePage"
name = "test.aspx"
title = "test"
pageLayout = "article"
showComments = $true
showRecommendedPages = $false
titleArea = @{
enableGradientEffect = $true
imageWebUrl = "https://cdn.hubblecontent.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 =
title = "sample1"
}
canvasLayout = @{
horizontalSections = @(
@{
layout = "oneThirdRightColumn"
id = "1"
emphasis = "none"
columns = @(
@{
id = "1"
width =
webparts = @(
@{
id = "6f9230af-2a98-4952-b205-9ede4f9ef548"
innerHtml = "<p><b>Hello!</b></p>"
}
)
}
@{
id = "2"
width =
webparts = @(
@{
id = "73d07dde-3474-4545-badb-f28ba239e0e1"
webPartType = "d1d91016-032f-456d-98a4-721247c305e8"
data = @{
dataVersion = "1.9"
description = "Show an image on your page"
title = "Image"
properties = @{
imageSourceType =
altText = ""
overlayText = ""
siteid = "0264cabe-6b92-450a-b162-b0c3d54fe5e8"
webid = "f3989670-cd37-4514-8ccb-0f7c2cbe5314"
listid = "bdb41041-eb06-474e-ac29-87093386bb14"
uniqueid = "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb"
imgWidth =
imgHeight =
fixAspectRatio = $false
captionText = ""
alignment = "Center"
}
serverProcessedContent = @{
imageSources = @(
@{
key = "imageSource"
value = "/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG"
}
)
customMetadata = @(
@{
key = "imageSource"
value = @{
siteid = "0264cabe-6b92-450a-b162-b0c3d54fe5e8"
webid = "f3989670-cd37-4514-8ccb-0f7c2cbe5314"
listid = "bdb41041-eb06-474e-ac29-87093386bb14"
uniqueid = "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb"
width = "4288"
height = "2848"
}
}
)
}
}
}
)
}
)
}
)
}
}
New-MgSitePage -SiteId $siteId -BodyParameter $params
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.site_page import SitePage
from msgraph.generated.models.page_layout_type import PageLayoutType
from msgraph.generated.models.title_area import TitleArea
from msgraph.generated.models.title_area_layout_type import TitleAreaLayoutType
from msgraph.generated.models.title_area_text_alignment_type import TitleAreaTextAlignmentType
from msgraph.generated.models.canvas_layout import CanvasLayout
from msgraph.generated.models.horizontal_section import HorizontalSection
from msgraph.generated.models.horizontal_section_layout_type import HorizontalSectionLayoutType
from msgraph.generated.models.section_emphasis_type import SectionEmphasisType
from msgraph.generated.models.horizontal_section_column import HorizontalSectionColumn
from msgraph.generated.models.web_part import WebPart
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SitePage(
odata_type = "#microsoft.graph.sitePage",
name = "test.aspx",
title = "test",
page_layout = PageLayoutType.Article,
show_comments = True,
show_recommended_pages = False,
title_area = TitleArea(
enable_gradient_effect = True,
image_web_url = "https://cdn.hubblecontent.osi.office.net/m365content/publish/005292d6-9dcc-4fc5-b50b-b2d0383a411b/image.jpg",
layout = TitleAreaLayoutType.ColorBlock,
show_author = True,
show_published_date = False,
show_text_block_above_title = False,
text_above_title = "TEXT ABOVE TITLE",
text_alignment = TitleAreaTextAlignmentType.Left,
additional_data = {
"image_source_type" : 2,
"title" : "sample1",
}
),
canvas_layout = CanvasLayout(
horizontal_sections = [
HorizontalSection(
layout = HorizontalSectionLayoutType.OneThirdRightColumn,
id = "1",
emphasis = SectionEmphasisType.None,
columns = [
HorizontalSectionColumn(
id = "1",
width = 8,
webparts = [
WebPart(
id = "6f9230af-2a98-4952-b205-9ede4f9ef548",
additional_data = {
"inner_html" : "<p><b>Hello!</b></p>",
}
),
],
),
HorizontalSectionColumn(
id = "2",
width = 4,
webparts = [
WebPart(
id = "73d07dde-3474-4545-badb-f28ba239e0e1",
additional_data = {
"web_part_type" : "d1d91016-032f-456d-98a4-721247c305e8",
"data" : {
"data_version" : "1.9",
"description" : "Show an image on your page",
"title" : "Image",
"properties" : {
"image_source_type" : 2,
"alt_text" : "",
"overlay_text" : "",
"siteid" : "0264cabe-6b92-450a-b162-b0c3d54fe5e8",
"webid" : "f3989670-cd37-4514-8ccb-0f7c2cbe5314",
"listid" : "bdb41041-eb06-474e-ac29-87093386bb14",
"uniqueid" : "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb",
"img_width" : 4288,
"img_height" : 2848,
"fix_aspect_ratio" : False,
"caption_text" : "",
"alignment" : "Center",
},
"server_processed_content" : {
"image_sources" : [
{
"key" : "imageSource",
"value" : "/_LAYOUTS/IMAGES/VISUALTEMPLATEIMAGE1.JPG",
},
],
"custom_metadata" : [
{
"key" : "imageSource",
"value" : {
"siteid" : "0264cabe-6b92-450a-b162-b0c3d54fe5e8",
"webid" : "f3989670-cd37-4514-8ccb-0f7c2cbe5314",
"listid" : "bdb41041-eb06-474e-ac29-87093386bb14",
"uniqueid" : "d9f94b40-78ba-48d0-a39f-3cb23c2fe7eb",
"width" : "4288",
"height" : "2848",
},
},
],
},
},
}
),
],
),
],
),
],
),
)
result = await graph_client.sites.by_site_id('site-id').pages.post(request_body)
Pour plus d’informations sur la façon d'ajouter le Kit de développement logiciel (SDK) à votre projet et créer une instance authProvider, consultez la documentation du Kit de développement logiciel (SDK).