Create SharePoint lists from JSON Using Power Automate

A few days ago, I worked on a flow that required creating multiple SharePoint lists and libraries automatically from a single JSON file. Instead of creating each one manually, I used Power Automate to read the JSON and create the SharePoint lists.

In this Power Automate tutorial, I will show you how to create SharePoint lists from JSON using Power Automate. Additionally, I will tell you how to create multiple libraries from a JSON file using Power Automate.

Create Multiple SharePoint Lists From JSON

In this flow, we will use a manual trigger that prompts the user to upload a JSON file. The uploaded file contains all the required details to create SharePoint lists or libraries, such as:

  • List Name
  • List Description
  • Base Template

Here’s an example of the JSON data we’ll use:

{
  "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"
    }
  ]
}

Now follow the steps below:

  1. Create an instant cloud flow. Once the flow opens, click on ‘Manually trigger a flow’. Then click on + Add an input Parameter -> Choose File that triggers manually.
power automate send http request to sharepoint parse json
  1. Add a Compose action and then pass the below expression to read the file content value.
base64ToString(triggerBody()?['file']?['contentBytes'])
power automate json to sharepoint list
  1. Click on ‘+ New step‘ and search for the ‘Parse JSON‘ action. Select it. In the Content field, click inside the box and select Outputs from the Compose action (which you used to read the file content).
  2. 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
  1. Add an Apply to each action. Select an output from the previous steps field (From the dynamic content pane, select List Information Details, which comes from the Parse JSON action output.)
Example to Create a SharePoint list from JSON using Power Automate

Note:

This will allow you to loop through each list or library definition (Title, Description, BaseTemplate) from your uploaded JSON file.

  1. 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']}"
}
json to sharepoint list power automate
  1. Click Save in the top-right corner of the flow editor. Click Test -> Choose Manually -> Then click Run flow. When prompted, upload your JSON file containing the list information and click Run. After the flow completes, go to your SharePoint site.
Create a SharePoint list from JSON using Power Automate flow

You will now see that the SharePoint lists have been created automatically, based on the details in your JSON file.

Create Multiple SharePoint Libraries From JSON

Just like we created multiple SharePoint lists using BaseTemplate 100, you can also create multiple document libraries by using BaseTemplate 101 in your JSON.

Here’s how your JSON can include libraries:

{
  "List Information Details": [
    {
      "Title": "Common Library",
      "Description": "Stores financial reports and statements",
      "BaseTemplate": "101"
    }
]
}
Create a SharePoint list from JSON using the Power Automate

Conclusion

With just a few flow actions, you can easily create SharePoint lists and document libraries from a JSON file using Power Automate.

In this tutorial, I explained to you how to create a flow that reads JSON input, parses it, and dynamically creates SharePoint lists or libraries based on the provided configuration.

You may also like:

  • >

    Build a High-Performance Project Management Site in SharePoint Online

    User registration Power Apps canvas app

    DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

    Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

    Power Platform Tutorial FREE PDF Download

    FREE Power Platform Tutorial PDF

    Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…