如何从站点页面获取“ webParts”

时间:2019-07-04 11:51:40

标签: microsoft-graph sharepoint-online microsoft-graph-sdks

我正在尝试使用图形API从Sharepoint网站获取页面。 但是当我们使用

发出GET请求时
https://graph.microsoft.com/beta/sites/{site-id}/pages/{page-id}

响应由仅具有类型和数据的webPart组成。 在数据内部,我们有一个id(与类型相同)和一个对每个webPart唯一的instanceId。

示例WebPart:

{
   "type": "d1d91016-032f-456d-98a4-721247c305e8",
   "data": {
             "id": "d1d91016-032f-456d-98a4-721247c305e8",
             "instanceId": "c54a74ef-86c1-44aa-9ba4-802e6841e3a7"
}

我的目标是获取具有完整详细信息的网页,然后将其以任何格式备份到本地驱动器。

图API的文档显示,响应将包含webPart的完整详细信息,但事实并非如此。 文档链接:https://docs.microsoft.com/en-us/graph/api/sitepage-get?view=graph-rest-beta&tabs=http

样品请求网址: https://graph.microsoft.com/beta/sites/m365x214355.sharepoint.com,c1e5444e-12d8-43d3-96b1-f2f66559ef58,b181bdf0-9680-4988-81f7-a24aee4afd6a/pages

Webpart响应:

"webParts": [
                {
                    "type": "rte",
                    "data": {
                        "innerHTML": "<p>Take a look at the team behind delivering amazing fashion events for Contoso.</p><p>Find out how the team uses the latest technology to plan amazing fashion shows and gather customer feedback for future events.</p><p>Meet the people behind Contoso's events, learn how to plan your own event, and find the necessary resources to run highly successful fashion shows, premiers, and extravaganzas!</p>"
                    }
                },
                {
                    "type": "d1d91016-032f-456d-98a4-721247c305e8",
                    "data": {
                        "id": "d1d91016-032f-456d-98a4-721247c305e8",
                        "instanceId": "c54a74ef-86c1-44aa-9ba4-802e6841e3a7"
                    }
                },
                {
                    "type": "b7dd04e1-19ce-4b24-9132-b60a1c2b910d",
                    "data": {
                        "id": "b7dd04e1-19ce-4b24-9132-b60a1c2b910d",
                        "instanceId": "75ccfeba-ad6c-416d-a859-4a6b114e156e"
                    }
                },
                {
                    "type": "b7dd04e1-19ce-4b24-9132-b60a1c2b910d",
                    "data": {
                        "id": "b7dd04e1-19ce-4b24-9132-b60a1c2b910d",
                        "instanceId": "f04e02fb-45e6-4e74-9f46-0c8d90e7fb8d"
                    }
                },
                {
                    "type": "275c0095-a77e-4f6d-a2a0-6a7626911518",
                    "data": {
                        "id": "275c0095-a77e-4f6d-a2a0-6a7626911518",
                        "instanceId": "c1a222b0-624e-4e30-b544-d2a67e8e1112"
                    }
                }

预期的响应格式:

"webParts": [
        {
            "type": "rte",
            "data": {
                "innerHTML": "<p>Here are the team's upcoming events:</p>"
            }
        },
        {
            "type": "d1d91016-032f-456d-98a4-721247c305e8",
            "data": {
                "title": "Events",
                "description": "Display upcoming events",
                "serverProcessedContent": {
                    "htmlStrings": {},
                    "searchablePlainTexts": {
                        "title": ""
                    },
                    "imageSources": {},
                    "links": {
                        "baseUrl": "https://www.contoso.com/sites/Engineering"
                    },
                    "componentDependencies": {
                        "layoutComponentId": "8ac0c53c-e8d0-4e3e-87d0-7449eb0d4027"
                    }
                },
                "dataVersion": "1.0",
                "properties": {
                    "selectedListId": "032e08ab-89b0-4d8f-bc10-73094233615c",
                    "selectedCategory": "",
                    "dateRangeOption": 0,
                    "startDate": "",
                    "endDate": "",
                    "isOnSeeAllPage": false,
                    "layoutId": "FilmStrip",
                    "dataProviderId": "Event",
                    "webId": "0764c419-1ecc-4126-ba32-0c25ae0fffe8",
                    "siteId": "6b4ffc7a-cfc2-4a76-903a-1cc3686dee23"
                }
            }
        }
    ]

我希望WebParts具有按照文档格式的格式。 如果instanceId是唯一的,则可能存在一些参考表来匹配这些instanceId,并获取详细的webParts结构。

0 个答案:

没有答案