Create SharePoint lists from JSON using Power Automate

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.

Create a SharePoint list from JSON using Power Automate flow

Step-2:

Add a Compose action and then pass the below expression to read the file content value.

base64ToString(triggerBody()['file']['contentBytes'])
Create a SharePoint list from JSON using Power Automate

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:
Create a SharePoint list from JSON using the Power Automate flow

Step-4:
Add an Apply to each action and pass the dynamic content value of list information details from Outputs of Parse JSON action.

Example to Create a SharePoint list from JSON using Power Automate
  • 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']}"
}
How to Create a SharePoint list from JSON using Power Automate flow

Step-5:

Save and run flow by selecting the run flow option. Once the flow ran successfully like below:

How to Create a SharePoint list from JSON using the Microsoft flow

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.

Create a SharePoint list from JSON using Power Automate flow example

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.

Create a SharePoint list from JSON using the Power Automate

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:

  • >