문제

I am wanting to fetch all of the associated data for the web parts of a SharePoint Page using the Microsoft Graph API. Is this possible through the beta or v1.0 API? I can't seem to find any documented endpoint that will return what I'm looking for.

I am able to fetch a page with https://graph.microsoft.com/beta/sites/{site_id}/pages/{page_id}/. This returns something like (with some information redacted):

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#sites('{site_id}')/pages/$entity",
    "eTag": "\"{48B279E3-D519-4C35-840D-7FBE18386CFB},23\"",
    "id": "{page_id}",
    "lastModifiedDateTime": "2020-03-23T14:39:49Z",
    "name": "PAGE TITLE.aspx",
    "webUrl": "SitePages/PAGE TITLE.aspx",
    "title": "PAGE TITLE",
    "pageLayout": "Article",
    "createdBy": {
        "user": {
            "displayName": "User Name",
            "email": "useremail@site.com"
        }
    },
    "lastModifiedBy": {
        "user": {
            "displayName": "User Name",
            "email": "useremail@site.com"
        }
    },
    "parentReference": {
        "siteId": "{site_id}"
    },
    "contentType": {
        "id": "0x0101009D1CB255DA76424F860D91F20E6C41180006521624A3273949ACA91134B5BDEB6C",
        "name": "Site Page"
    },
    "webParts": [
        {
            "type": "d1d91016-032f-456d-98a4-721247c305e8",
            "data": {
                "id": "d1d91016-032f-456d-98a4-721247c305e8",
                "instanceId": "19af885c-15a2-4807-b342-d89777e43082"
            }
        },
        {
            "type": "rte",
            "data": {
                "innerHTML": "<p>HTML content here.</p>"
            }
        }
    ],
    "publishingState": {
        "level": "published",
        "versionId": "3.0"
    }
}

As you can see, the full content of rte elements are returned, but other elements are not. The first web part returned is an image (type d1d91016-032f-456d-98a4-721247c305e8) but I can't figure out how to grab the source or other properties of the image outside of the instanceId.

Is there a way I can modify my API call or use the instanceId to make a second API call to fetch these properties?

Since the pages I am fetching are items in a list I am also able to fetch the page with https://graph.microsoft.com/beta/sites/{site_id}/lists/{list_id}/items/{item_id} which returns something like:

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#sites('{site_id}')/lists('{list_id}')/items/$entity",
    "@odata.etag": "\"c06280ef-c923-4089-acde-93edfb9c8f7d,22\"",
    "createdDateTime": "2019-10-18T14:41:54Z",
    "eTag": "\"c06280ef-c923-4089-acde-93edfb9c8f7d,22\"",
    "id": "{item_id}",
    "lastModifiedDateTime": "2019-10-18T19:15:41Z",
    "webUrl": "https://mysite.com/SitePages/PAGE-TITLE.aspx",
    "createdBy": {
        "user": {
            "email": "useremail@site.com",
            "id": "{user_id}",
            "displayName": "User Name"
        }
    },
    "lastModifiedBy": {
        "user": {
            "email": "useremail@site.com",
            "id": "{user_id}",
            "displayName": "User Name"
        }
    },
    "parentReference": {
        "id": "{parent_id}",
        "siteId": "{site_id}"
    },
    "contentType": {
        "id": "0x0101009D1CB255DA76424F860D91F20E6C41180006521624A3273949ACA91134B5BDEB6C",
        "name": "Site Page"
    },
    "fields@odata.context": "https://graph.microsoft.com/beta/$metadata#sites('{site_id}')/lists('{list_id}')/items('{item_id}')/fields/$entity",
    "fields": {
        "@odata.etag": "\"c06280ef-c923-4089-acde-93edfb9c8f7d,22\"",
        "FileLeafRef": "PAGE-TITLE.aspx",
        "Title": "PAGE TITLE",
        "Description": "Page description…",
        "LinkTitle": "PAGE TITLE",
        "Category": "Custom Field Value",
        "promoted": "2",
        "id": "{item_id}",
        "ContentType": "Site Page",
        "Created": "2019-10-18T14:41:54Z",
        "Modified": "2019-10-18T19:15:41Z",
        "_CheckinComment": "",
        "LinkFilenameNoMenu": "PAGE-TITLE.aspx",
        "LinkFilename": "PAGE-TITLE.aspx",
        "DocIcon": "aspx",
        "FileSizeDisplay": "5144",
        "ItemChildCount": "0",
        "FolderChildCount": "0",
        "_ComplianceFlags": "",
        "_ComplianceTag": "",
        "_ComplianceTagWrittenTime": "",
        "_ComplianceTagUserId": "",
        "_CommentCount": "",
        "_LikeCount": "",
        "_DisplayName": "",
        "Edit": "0",
        "_UIVersionString": "4.0",
        "ParentVersionStringLookupId": "22",
        "ParentLeafNameLookupId": "22"
    }
}

This endpoint gives the fields associated with the page (or list item in this case) but does not return any information on the associated web parts.

Is it possible to modify the list item API query to get the web parts for the item and all of their properties?

도움이 되었습니까?

해결책

Graph API is fairly limited when it comes to SharePoint as a resource. There is no endpoint for getting Webpart information, unfortunately. Hopefully, it will be added eventually.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top