Share via

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
Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    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.

    Was this answer helpful?


Your answer

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