In this SharePoint tutorial, I will show you how to create SharePoint lists from JSON using Power Automate. I will show you how to create multiple lists and libraries from a JSON file in Power Automate.
Scenario:
The flow uses a manual trigger and requests the user to Upload a JSON data file that contains all the list information like:
- List Name
- List Description
- Base Template
In this example, I’m going to use the below JSON data:
{
"List Information Details": [
{
"Title": "SharePoint Team",
"Description": "This List Contains SharePoint Team Details",
"BaseTemplate": "100"
},
{
"Title": "Python Team",
"Description": "This List Contains Python Team Details",
"BaseTemplate": "100"
},
{
"Title": "Database Team",
"Description": "This List Contains Database Team Details",
"BaseTemplate": "100"
},
{
"Title": "Common Library",
"Description": "This Library Contains",
"BaseTemplate": "101"
},
]
}
Later, we will get the file content values using compose action. We will use the Parse JSON action to get the JSON code; then, we use Send an HTTP request to SharePoint action to create a new SharePoint Online List using flow.
Follow the below steps to create a list or library from a JSON file in Power Automate.
How to Create a SharePoint list from JSON using Power Automate flow
Let us see, how to create a SharePoint list from JSON using Power Automate flow.
Step-1:
Create an instant cloud flow that triggers manually. Expand the Trigger and add File content as input.
Step-2:
Add a Compose action and then pass the below expression to read the file content value.
base64ToString(triggerBody()['file']['contentBytes'])
Step-3:
- Select +New step and choose Parse JSON action from the action triggers, and pass the Outputs of the Compose action in Content as highlighted below:
- In the Schema, pass the sample JSON object value and choose done. It will automatically generate the JSON schema as below:
Step-4:
Add an Apply to each action and pass the dynamic content value of list information details from Outputs of Parse JSON action.
- Add an action ‘Send an HTTP request to SharePoint‘ from action triggers and provide the SharePoint site address.
- Method- POST
- Uri- /_api/web/lists
- Headers-
- Accept – application/json;odata=verbose
- content-type – application/json;odata=verbose
- Body: Add the below JSON code to create a new list using Rest API and dynamically pass the JSON content values for Title, Description, and Base Template.
{
"__metadata": {
"type": "SP.List"
},
"AllowContentTypes": true,
"BaseTemplate": @{items('Apply_to_each')?['BaseTemplate']},
"ContentTypesEnabled": true,
"Description": "@{items('Apply_to_each')?['Description']}",
"Title": "@{items('Apply_to_each')?['Title']}"
}
Step-5:
Save and run flow by selecting the run flow option. Once the flow ran successfully like below:
The SharePoint Lists have been created for the first three JSON Object data values parsed in our JSON file with the base template of 100.
Similarly, we can see that a new document library was created for the fourth JSON object data values parsed in our JSON file with the base template 101.
This is how to create a SharePoint list from JSON using Power Automate flow.
Conclusion
Using a few flow actions, we can easily create lists and libraries from a JSON file using Power Automate. In this Power Automate tutorial, I have explained to you how to create a SharePoint list from JSON using Power Automate flow with an example.
You may also like:
- Create an array from a string using Power Automate
- Send Teams Messages using Power Automate
- Create an Array from SharePoint list Items using Power Automate
- The property ‘__metadata’ does not exist on type ‘SP.List’
- How to create an array from JSON objects using Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
Interesting content.