1

I created a SharePoint Page in SitePages library using the new SharePoint online experience. The page was created and I tried to fetch the page properties using MS Graph endpoint:

https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/site_page.aspx?expand=listItem

The response I got:

{
    ...
    "name": "site_page.aspx",
    ...
    "file": {
        "mimeType": "application/xml",
        "hashes": {
            "quickXorHash": ""
        }
    },
    ...
    "listItem": {
        ...
        "id": "4",
        ...
        "contentType": {
            "id": "0x0101009D1CB255DA76424F860D91F20E6C411800020BAE24978F3545AFD24007B325ACF9"
        },

        "fields": {
            "FileLeafRef": "site_page.aspx",
            "Title": "site_page",
            "LinkTitle": "site_page",
            "id": "4",
            "ContentType": "Site Page",
            ...
        }
    }
}

Then I added Wiki Page content to this library to support Wiki pages in my site. I created a new Wiki Page and fetched the page properties again using MS Graph endpoint:

    https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/wiki_page.aspx?expand=listItem

The response I got:

    {
    ...
    "name": "wiki_page.aspx",
    ...
    "file": {
        "mimeType": "application/xml"
    },
    ...
    "listItem": {
        ...
        "id": "5",
        ...
        "contentType": {
            "id": "0x0101009D1CB255DA76424F860D91F20E6C411800020BAE24978F3545AFD24007B325ACF9"
        },

        "fields": {
            "FileLeafRef": "wiki_page.aspx",
            "Title": "wiki_page",
            "LinkTitle": "wiki_page",
            "id": "5",
            "ContentType": "Site Page",
            "WikiField" : "..."
            ...
        }
    }
}

As you can see both items have the same Content Type. How that is possible? The only difference being that the wiki_page Item doesn't include 'hashes' property and does include 'WikiField' property (the place where the wiki page content is stored). Is there another way to distinguish page types?

1 Answers1

0

You could try this endpoint: GET /sites/{site-id}/lists/{list-id}/items?expand=fields(select= ContentType)

My test result:

{
            "@odata.etag": "\"b3b04ace-40cd-4847-a3d8-678bc658216d,2\"",
            "createdDateTime": "2020-04-22T05:34:06Z",
            "eTag": "\"b3b04ace-40cd-4847-a3d8-678bc658216d,2\"",
            "id": "11",
            "lastModifiedDateTime": "2020-04-22T05:34:06Z",
            "webUrl": "https://xxxx.sharepoint.com/sites/dev/SitePages/wikipage.aspx",
            "createdBy": {
                "user": {
                    "email": "amos@xxxx.onmicrosoft.com",
                    "id": "fc1e9add-6f9c-4b95-83e1-a022441681d7",
                    "displayName": "test"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "amos@xxxx.onmicrosoft.com",
                    "id": "fc1e9add-6f9c-4b95-83e1-a022441681d7",
                    "displayName": "test"
                }
            },
            "parentReference": {
                "id": "79e13173-d5ee-4a17-a081-5c94d148f905",
                "siteId": "xxxx.sharepoint.com,b57886ef-4c2a-4d56-ad29-27266638ac3b,b62d1450-8e6f-4be7-84a3-f6600fd6cc14"
            },
            "contentType": {
                "id": "0x01010800511BB12BD4FB664A89516226DBDDF1FB"
            },
            "fields@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('siteid')/lists('63307f0b-bc1c-4372-bfea-6352ed57a0ff')/items('11')/fields/$entity",
            "fields": {
                "@odata.etag": "\"b3b04ace-40cd-4847-a3d8-678bc658216d,2\"",
                "ContentType": "Wiki Page"
            }
        },
        {
            "@odata.etag": "\"70f12845-7646-4b2b-85bd-4a8074c105a0,1\"",
            "createdDateTime": "2020-04-22T05:35:54Z",
            "eTag": "\"70f12845-7646-4b2b-85bd-4a8074c105a0,1\"",
            "id": "12",
            "lastModifiedDateTime": "2020-04-22T05:35:54Z",
            "webUrl": "https://xxxx.sharepoint.com/sites/dev/SitePages/webpartpage.aspx",
            "createdBy": {
                "user": {
                    "email": "amos@xxxx.onmicrosoft.com",
                    "id": "fc1e9add-6f9c-4b95-83e1-a022441681d7",
                    "displayName": "test"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "amos@xxxx.onmicrosoft.com",
                    "id": "fc1e9add-6f9c-4b95-83e1-a022441681d7",
                    "displayName": "test"
                }
            },
            "parentReference": {
                "id": "79e13173-d5ee-4a17-a081-5c94d148f905",
                "siteId": "xxxx.sharepoint.com,b57886ef-4c2a-4d56-ad29-27266638ac3b,b62d1450-8e6f-4be7-84a3-f6600fd6cc14"
            },
            "contentType": {
                "id": "0x0101090100FAC6DAD225005749BE7D6124B50B156E"
            },
            "fields@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('siteid')/lists('63307f0b-bc1c-4372-bfea-6352ed57a0ff')/items('12')/fields/$entity",
            "fields": {
                "@odata.etag": "\"70f12845-7646-4b2b-85bd-4a8074c105a0,1\"",
                "ContentType": "Web Part Page"
            }
        }

You'd better check the type of your page.

Updatded:

enter image description here

"fields@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('siteid')/lists('63307f0b-bc1c-4372-bfea-6352ed57a0ff')/items('13')/fields/$entity"
    "fields": {
                    "@odata.etag": "\"18361706-416b-4a71-8d31-bce87c1a57e4,3\"",
                    "ContentType": "Site Page"
                }
Amos
  • 2,030
  • 1
  • 5
  • 9