SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 1.01k forks source link

Sharepoint Graph API Pages folder creation broke this week #9227

Open kkgthb opened 1 year ago

kkgthb commented 1 year ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint REST API

Developer environment

None

What browser(s) / client(s) have you tested

Additional environment details

No response

Describe the bug / error

Using the graph explorer, I logged into it as myself and tried to do a POST request to https://graph.microsoft.com/beta/sites/the-id-of-my-sharepoint-site/pages with a body of:

{
    "name": "pets/Dog/index.aspx",
    "title": "All about dogs",
    "pageLayout": "article",
    "@odata.type": "#microsoft.graph.sitePage"
}

Last week, when done against a site where I had the creation of subfolders enabled, doing this automatically created 2 subfolders in my site if they didn't yet exist: "pets" and, within it, "Dog". It then created a Site Page whose name was index.aspx and whose webUrl was SitePages/pets/Dog/index.aspx. Since there is no dedicated Graph API endpoint for creating a subfolder in a site, this was the only way to build out a folder hierarchy by API (rather than manually, clicking around in Sharepoint Pages in a web browser).

Today, this started 404-ing out when I tried to create one by the name of pets/Cat/index.aspx. I could still create, say, pets/testing123.aspx, because the "pets" folder already existed, but putting the name of a folder that did not yet exist into the name property started 404-ing out this week after auto-creating the folder last week.

I deleted the entire "pets" folder and my code from last week, with pets/Dog/index.aspx also started 404-erroring out as well with a response body like this:

{
    "error": {
        "code": "itemNotFound",
        "message": "Item not found",
        "innerError": {
            "date": "datestamp-here",
            "request-id": "request-id-here",
            "client-request-id": "client-request-id-here"
        }
    }
}

Can Microsoft please urgently either:

  1. Restore the ability to auto-create subfolders that do not yet exist by specifying the subpath in the "name" property of a new page's request body, or
  2. Provide a Graph API endpoint for the management of Sharepoint Site Pages subfolders (in sites where subfolders are enabled)?

We have an application that is now completely broken because of this week's failure.

Thank you!

Steps to reproduce

  1. Enable folders in your Sharepoint site's pages
  2. Make sure your site pages doesn't yet have a "pets" subfolder
  3. Open the graph explorer and try to do a POST request to https://graph.microsoft.com/beta/sites/the-id-of-your-sharepoint-site/pages with a body of:
    {
        "name": "pets/Dog/index.aspx",
        "title": "All about dogs",
        "pageLayout": "article",
        "@odata.type": "#microsoft.graph.sitePage"
    }
  4. Confirm you get a 404 error.
  5. Manually go to your Sharepoint site pages file list (https://your-org.sharepoint.com/teams/Your-Site-Name/SitePages/Forms/ByAuthor.aspx), create a new folder in it called pets, and one within that called Dog, and then try again.
  6. Confirm you get a 201 response with a response body showing you a page ID, a name of index.aspx, and a webUrl of SitePages/pets/Dog/index.aspx. (This demonstrates that the API still has some idea how to handle the idea of subfoldering via the page-creation name property -- it's just the auto-creation of folders that suddenly broke this week.)

Expected behavior

I expected to get the 201 response I received in steps 5-6 during steps 3-4 instead, like I did last week (when the API auto-created "pets" and "Dog" subfolders on my behalf).

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.