Add new folder in SharePoint List using Microsoft Flow

Microsoft Flow is a Cloud based automation service available as a component in Office 365, that enables us to build the workflow process across different applications / services. There are n number of Microsoft and Third party applications can associate with the Flow to develop the seamless process across different application without moving away.

For each application, Microsoft Flow provides the different activities, trigger points to automate the business process. Microsoft Flow also provides unique activities and trigger points for SharePoint. The below link provides the details about each actions, triggers,

https://docs.microsoft.com/en-us/connectors/sharepointonline/

Though it has lot of actions, still Flow has limited services and that didn’t allow us to achieve some functionalities. To overcome some of the limited areas, recently Microsoft added a new action to the Microsoft Flow for SharePoint. That enables us to send SharePoint REST API requests to achieve the most of the SharePoint functionalities using the action called Send an HTTP request to SharePoint

Follow the below steps to use the Send an HTTP request to SharePoint action to create a folder in SharePoint List.

Scenario: We have two lists called Employee List and Employee Contents List. Whenever a new item is created in Employee List, a folder will be created in Employee Contents List in the same name of title in Employee List.

  1. Select Flow from Office 365 App Launcher, to navigate to Microsoft Flow page
  2. In the Flow site, click Create from Blank button to initiate the Flow creation,
Create From Blank
Img1: Create From Blank
  1. Select When an item is created button to open a workflow designer page. We can also select Create from blank to navigate to workflow designer page.
Template Selection
Img 2: Template Selection
  1. In the designer page; name the flow as Create Folder
  2. In the designer page; Provide the trigger information by selecting Site URL and List name from the SharePoint,
Action for Triggering Flow
Img 3: Action for Triggering Flow
  1. Click New Step button and click on Add an action button. This will open a list of available actions in a popup, from the list of actions, select Send an HTTP request to SharePoint action
Send an HTTP request to SharePoint - Action
Img 4: Send an HTTP request to SharePoint – Action
  1. Selecting the HTTP action opens a parameters box in a same page. There enter Site Address, select request method, Enter REST API url in URI and Headers
Site Address https://tenant.sharepoint.com
Method POST
Uri _api/web/GetFolderByServerRelativePath(decodedurl=’/lists/listname’)/

AddSubFolderUsingPath(decodedurl=’foldername’)

Headers {

“accept”: “application/json; odata=verbose”

}

After filling the details, the request action should look like below screenshot

Action Details
Img 5: Action Details

We have selected Title from the dynamic content from the Triggered List. So that after creating the item, the title from the item used as a folder name.

 

  1. After filling up the inputs, click Save button to save the Flow.

To test it, create a new item in Employee List and navigate to Flow to check the status of the instance.

Success Status of MS Flow Instance
Img 6: Success Status of MS Flow Instance

The green tick represents the success status. So, both of the action in our Microsoft Flow instance gets success and the ShanthaKumarT folder is created under Employee Contents SharePoint List.

Hence, by using this Send an HTTP request to SharePoint enables the lot of possibilities to work against the SharePoint objects through Microsoft Flow.

Shantha Kumar
Shantha Kumar
Articles: 296

24,849 Comments

  1. Using my previous manager’s blog post in my change request at the moment. Feeling proud #Shantha rocks! Can’t forget the days when he trained us the beginning steps of development !!!

  2. This post was very helpful. I was able to successfully create a flow to add a new folder in the documents library when a new list item is added. Love it! From that flow, I am adding in an approval process. I’d like to link the user back to the folder, not the flow. Can you give me some tips on how to do that?

    I appreciate your time.

  3. Hi Shantha,

    I change a little bit your scenario.

    We have two lists called Employee List and Employee Contents List both with folders (ex: Departments). Whenever a new item is created in Employee List, an item will be created in Employee Contents List in the same folder of Employee List.
    Ex : New Employee in the Finances folder in the Employee List and a new item created in Finances folder to the Employee Contents List.

    Do you know how to do it ?
    Best regards,

  4. please can anyone tell me why “send HTTP request to SharePoint” action times out. This behaviour is intermittent

  5. Can you let me know how can i create Folder in Sharepoint if do not exists bases on Inbox Receipients list and save the document to folders based on list.

  6. Hi Santha Kumar,

    I am new to MS Flow creation. Currently, I am working on the exact same requirement which is need for our customers as you mentioned in this post. My flow works fine where folder structure is followed and copied, but again it is returning the items of subfolders in the library a recursive way (it is returning items many subfolders deep).

    It will be helpful if you could share the complete flow along with the code which will help me to complete the same and analyze the issue caused in my flow. Appreciate your quick response.

  7. I am trying to create a flow to do the following:

    Search through a large SharePoint document library (100k+ items) for files which have not been modified in 3 years.

    If the flow locates a file which matches the condition, this file needs to be moved to an archive library which is on the same site.

    Requirement Details for your reference:

    The file must keep the same folder structure when moved into the archive library.

    I.e Library 1/Customer 1/Folder 1/File.docx -moves to-> Archive Library/Customer 1/Folder 1/File.docx

Comments are closed.