Using the Pages GraphAPI, HTML headers are not returned if they are set to be collapsed by default

Tekin, Ender 0 Reputation points
2023-12-05T15:03:15.54+00:00

I'm using GraphAPI to access site pages published in a Sharepoint site to retrieve the html content. Normally, the innerHtml field contains the html I am looking for. However, there are some pages that have their headers collapsed by default. In this case, only the content of the sections are returned, but the HTML headers (<h2> tags) themselves are not returned as part of the innerHtml or otherwise. Is this an issue with the API, or is there another way to retrieve the headers?

The call is (using the Pages API, which I am aware is in beta):

GET https://graph.microsoft.com/beta/sites/<site_id>/pages/<page_id>/microsoft.graph.sitePage?expand=webParts
SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,413 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,867 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,117 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 38,111 Reputation points Microsoft Vendor
    2023-12-06T06:11:42.1866667+00:00

    Hi @Tekin, Ender,

    Per my test, I am unable to get the HTML headers of the pages have their headers collapsed by default. It turns out to be a by-design one. Graph api doesn't support to fetch the resource when they are collapsed.

    It is highly recommended that you can vote this ticket. Many features of our current products are designed and upgraded based on customers’ feedback. With requirements like this increase, the problem may well be released in the future. Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.