Forum Discussion

Eliot_Cole's avatar
Eliot_Cole
Iron Contributor
Feb 15, 2024
Solved

REST API - Unable To Create Folder In Newly Created Team Site SiteAssets Library (Owned)

Incident

When I try to create a subfolder in the SiteAssets library with the following call, I keep getting unauthorised (or similar) responses.

 

POST urlhttps://TENANT_SUBDOMAIN.sharepoint.com/sites/SITE_PATH/_api/web/folders
Body{ "ServerRelativeUrl": "/sites/SITE_PATH/SiteAssets/SitePages" }

 (annoyingly getting errors trying to submit the body in a codeblock, sorry)

 

Can anyone assist, please?

 

Further information is in the spoiler below ...

Spoiler

Further Information

Once in a blue moon this actually just decides to work, but it's very rare. The folder being created is SitePages, and I have the same/similar error when using default flow actions. Adding a space to 'SiteAssets' does not help.

  • REST API Only - I am operating *purely* via the REST API and my workflow has made the site and applied a site design
  • Fully Authorised - The user who is authorised is the owner of the new site individually and not as part of a group
  • Interface - I am using Power Automate AND Logic Apps with the same results to get this - PLUS - No paid licence, so no premium connectors.
  • Site Assets Exists - When I load the Site Contents (see below) it shows the Site Assets library and I have accessed it.

If I go to a separate request stream (even while that is retrying) I am able to send the request.

 

Is this some kind of lock-out?
 
I have a feeling simply by opening the site for the first time it suddenly enables the above API to work ... but I don't know an API call to do that.

 

Attempts To Activate The Site

Since I believe that this is actually something related to 'first access' I have been trying a number of things to awaken the site.

These include the following API calls:

  1. POST _api/web/AppTiles
  2. POST _api/web/SiteUserInfoList/GetItems
  3. POST _api/GroupService/SyncGroupProperties
  4. PATCH _api/Web with property 'NextStepsFirstRunEnabled' set to false
  5. PATCH _api/Web with property 'NextStepsFirstRunEnabled' set to false

Potentially Related Information

Also, I don't know if this is relevant, but I have noted that when looking at the status of the earlier SiteScript in the workflow that there are folder actions which are not getting the default '0' result. Which I am assuming is an error.
 
The issues here are returning the following:

(again, apologies for lack of code, it won't accept when I add code)
                        {
                            "ActionIndex"1,
                            "ActionKey""00000000-0000-0000-0000-000000000000",
                            "ActionTitle""Add content type \"Folder\"",
                            "LastModified""1708004048000",
                            "OrdinalIndex"23,
                            "OutcomeCode"2,
                            "OutcomeText"null,
                            "SiteScriptID""66f91246-a63c-4f02-9b6c-fdf2f1c73771",
                            "SiteScriptIndex"0,
                            "SiteScriptTitle""36 - Project Site Script Template - 20240215012958"
                        }

 

  • OK, it looks like there is an answer, and I got it from the 365 / Power Platform community.

     

    Essentially, since there is no requirement for the Site Assets until someone has looked at anything, then the library is either not enabled or provisioned in some way.

     

    annajhaveri, over at the Power Automate community supplies the actual call needed to do this:

     

    POST - _api/web/lists/ensureSiteAssetsLibrary

     

    This then allows actions on that library without loading the site.

1 Reply

  • Eliot_Cole's avatar
    Eliot_Cole
    Iron Contributor

    OK, it looks like there is an answer, and I got it from the 365 / Power Platform community.

     

    Essentially, since there is no requirement for the Site Assets until someone has looked at anything, then the library is either not enabled or provisioned in some way.

     

    annajhaveri, over at the Power Automate community supplies the actual call needed to do this:

     

    POST - _api/web/lists/ensureSiteAssetsLibrary

     

    This then allows actions on that library without loading the site.

Resources