0

I am making a Power automate flow where I am creating a subsite. I m able to do that successfully with below link: https://www.annajhaveri.com/sharepoint/create-a-sharepoint-online-subsite-from-power-automate-flow

Now I want to create a folder in those subsite. I am using send HTTP request to SharePoint action and using post method.

For that below are the inputs i have provided:

Site Address - Site where I have created a subsite.

Method - Post

Uri - /_api/web/folders

Headers -

Accept
application/json;odata=verbose

Content-Type
application/json;odata=verbose

Body -

{
  "__metadata": { "type": "SP.Folder" },
  "ServerRelativeUrl":"ServerRelativeURL(this is taken from parse JSON output)/testFolder"
}

For this input i am getting forbidden error. What am i doing wrong? I have site Admin access to the sharepoint site.enter image description here

7
  • Can you show us the output format of ServerRelativeUrl parameter? Commented Oct 9, 2024 at 14:08
  • I am getting server relative url parameter as below "ServerRelativeUrl": "/sites/testsite1/test56" Commented Oct 9, 2024 at 14:11
  • Is test56 your subsite name? Generally, you can create a folder "inside" a document library. So, you will have to use the ServerRelativeUrl including document library URL NOT just subsite URL. Commented Oct 9, 2024 at 14:17
  • Yes test56 is a subsite. SO first I will need to create a library on this subsite using send HTTP action right? Commented Oct 9, 2024 at 14:20
  • SharePoint by default creates one library with name Documents (Shared Documents). You can use it if you don't need any custom document library for your use case. Commented Oct 9, 2024 at 14:21

1 Answer 1

0

I think you are missing document library URL part in your ServerRelativeUrl parameter to HTTP action.

When you create a site or subsite in SharePoint, it automatically creates one document library, named "Documents" with URL name as Shared Documents.

If you want to create a new folder inside this document library, try using ServerRelativeUrl parameter like:

"ServerRelativeUrl": "/sites/testsite1/test56/Shared Documents/folder1"

Refer below Microsoft official documentation and other link for more information:

  1. Working with folders and files using SharePoint REST API
  2. Will SharePoint automatically create intermediary folders when adding a file through the REST API?
1
  • yes i have updated the path /sites/testsite1/test56/Shared%20Documents/01_data1 this time i gave path to shared documents as above to create 01_data1 folder but it is giving me below error Passing in an empty or null value of parameter 'strTitle' Commented Oct 9, 2024 at 14:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.