Updating a webpart in a site page which has the vertical section using Graph API

KosakaTomoya-3980 25 Reputation points
2024-10-12T14:10:06.08+00:00

I am using the Microsoft Graph API to modify a site page in a modern team site using the following

https://learn.microsoft.com/en-us/graph/api/webpart-update?view=graph-rest-1.0

I request the following in an attempt to update a webpart.

PATCH /sites/{site-id}/pages/{page-id}/microsoft.graph.sitePage/webParts/{webpart-id}
PATCH /sites/{site-id}/pages/{page-id}/microsoft.graph.sitePage/canvasLayout/verticalSection/webparts/{webpart-index}
PATCH /sites/{site-id}/pages/{page-id}/microsoft.graph.sitePage/canvasLayout/horizontalSections/{horizontal-section-id}/columns/{horizontal-section-column-id}/webparts/{webpart-index}

At first I try to update a site page which has no vertical section. And the request works well.

Next, I try to update a site page which had the vertical section. And the response has the following error.

{
    "error": {
        "code": "invalidRequest",
        "message": "Cannot have vertical section and full width horizontal section at the same time",
        "innerError": {
            "code": "badArgument",
            "date": "2024-10-12T12:28:29",
            "request-id": "aac28419-9eca-41f9-8d68-669457368034",
            "client-request-id": "6588f432-9aae-6681-c96c-faf7fb2e5380"
        }
    }
}

The page has a webpart for the page title, which is a full width layout within the horizontal section, which is also present on all other pages.

I can create and modify the following page in my browser. But I can not modify the same page with Graph API. The page with the vertical section

Any pointers are appreciated.

Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Xyza Xue_MSFT 30,176 Reputation points Microsoft External Staff
    2024-10-14T06:45:35.6166667+00:00

    Hi @KosakaTomoya-3980 ,

    The error message you are encountering indicates that the page cannot have both a vertical section and a full-width horizontal section simultaneously. This limitation is enforced by the Microsoft Graph API when updating site pages.This is a limitation within the Microsoft Graph API when dealing with site pages that have specific layout configurations.

    To resolve this issue, you should ensure that your page layout does not include both types of sections simultaneously. If you need to maintain a vertical section, consider removing or modifying the full-width horizontal section before attempting to update the web part.

    You can create and modify pages in the browser, but the Graph API enforces these layout rules strictly, which may lead to such errors.


    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.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2024-10-12T14:10:06.0933333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The error message you received indicates that a site page cannot have both a vertical section and a full-width horizontal section at the same time. This limitation is likely due to the layout constraints of modern SharePoint pages, which dictate that certain section types cannot coexist.

    To resolve this issue, you should ensure that your page's layout is consistent with the types of sections you are trying to implement. If you want to use a vertical section, make sure that the page does not include any full-width horizontal sections. Alternatively, if you need a full-width layout, consider restructuring the page to avoid using vertical sections.

    For further assistance, you may want to review the specific requirements and limitations regarding section layouts in modern SharePoint pages.


    References:

    0 comments No comments

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.