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.
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,
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,
- {
- '__metadata':{ 'type':'SP.List' },
- 'AllowContentTypes': true,
- 'BaseTemplate':101,
- 'ContentTypesEnabled':true,
- 'Description':"",
- 'Title': '@{triggerOutputs()?['body/Title']}'
- }
Step 9
After filling up all fields values, send an HTTP request to SharePoint action which will be displayed as below,
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!