Create Document Library In SharePoint Using Power Automate

Introduction

 
In this blog, we will learn how can we create a document library using MS Flow.
 
There is no action available in flow to create a document library. So, to create a document library we need to use rest API, and to use rest API in MS flow we will send an HTTP request to SharePoint action.
 

Steps to create a document library

  • To get started with this example create a new SharePoint List - for this example we will use the Title field but you could end up using any column you wish.
  • So, when a new item is created in the list and you type the title, the flow will create a document library with the name entered in the title of the list.
Step 1
 
Create automated cloud flow and select trigger when the item is created.
 
Step 2
 
Select Site Address and List Name.
 
Create document library in SharePoint using Power Automate
 
Step 3
 
Now add new action Send an HTTP request to SharePoint.
 
Step 4
 
In a Site Address field, select the site in which you want to create a document library.
 
Step 5
 
In the Method field, select option POST.
 
Step 6
 
In Uri field, enter below Uri,
  1. _api/web/lists  
Step 7
 
In header, add below key value pair,
 
 accept  application/json;odata=verbose
 content-type  application/json;odata=verbose
 
Step 8
 
In the Body field, add the below JSON. You can copy the JSON code from below directly into the Body of your action,
  1. {  
  2.    '__metadata':{ 'type':'SP.List' },  
  3.    'AllowContentTypes'true,   
  4.    'BaseTemplate':101,   
  5.    'ContentTypesEnabled':true,  
  6.    'Description':"",   
  7.    'Title''@{triggerOutputs()?['body/Title']}'  
  8. }  
Step 9
 
After filling up all fields values, send an HTTP request to SharePoint action which will be displayed as below,
 
Create document library in SharePoint using Power Automate
 
Once you have configured the action and saved your flow you can click the Test button. If this is the first time the flow has run it will ask you to perform the action on the target list so go ahead and create a list item.
 
Your flow should be successful and you will have a new Document Library.
 
Hope this blog will be helpful!