Create a SharePoint list in Power Automate

So your flow is creating a new SharePoint site and now you want to create a SharePoint list in the site as well. Can this be done in Power automate?

SharePoint REST API and Power Automate

In the past I wrote many posts about how to do things in SharePoint with Power Automate. so far I haven’t had a need to create SharePoint list yet.

SharePoint REST API and Power Automate flows.

In the past I tried many of the options available with the Send and HTTP request to SharePoint . I collected all these posts in the User Guide to the REST API in Power Automate.

Today I’m going to add a list to a SharePoint site.

Create a SharePoint list to a SharePoint site

First I’m going to add a simple list to the site

Within the Site address i’m selecting my site collection in SharePoint.

Within the Method I’m using POST

and the Uri points at the _api/web/lists end point.

Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online create a sharepoint list in power automate

Nothing too complicated.

The body, I’m setting to the following json:

{
  "AllowContentTypes": true,
  "BaseTemplate": 100,
 "ContentTypesEnabled": true,
 "Description": "My list description",
 "Title": "Test"
}
Create a SharePoint list

And my list is created!

Now we need to add some columns

Adding a column to a SharePoint list

The next step is to create a custom column.

First I’m going to add a column, that of the simply text type.

Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online image 23

The body

{ '__metadata': { 'type': 'SP.Field' }, 
     'FieldTypeKind': 2, 
     'Title':'My Custom Column'
}
   

If you need to create other types of columns then please have a look at the list of column types.

Now come the important questions…

  • Should we use site columns?
  • Should we use content types?
  • Should we add this column to the content type?

For a very long time i thought that SharePoint was all about content types and site columns. In the 2007 and 2010 versions of SharePoint, we ‘proper developers’ deployed everything using SharePoint solutions.

Every project we spend a lot of time getting the content types and site columns right.

But now that content types is harder and harder to configure. Should we still bother?

When you create a new team in Microsoft Teams and a document library holds my documents is created. Things like Site Settings are multiple clicks away and hidden away under site information.

This while adding new fields to SharePoint lists has been made so much easier.

Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online image 24

Ok, there may still be some needs for content types, e.g. if you want to connect a selective group columns to types of data, but often multiple lists or libraries could do that as well.

The other important reason for site columns for me has always been to ensure that my columns are called the same within the lists where I use the columns. With the method described in this post I can get that done.

Is it possible to create content types and use site columns with the SharePoint REST API approach?

Create a content type

It is possible to do a POST to _api/web/contenttypes and then a body like this will create you a content type:

{
   'Name': 'New Content Type', 
   'Description': 'New Content Type Description',
   'Group': 'Custom Content Type Group'
}

Retrieve Site column details

Before we can add a site column to a list we will first need to retrieve it from the site. by calling the following end point.

/_api/web/Fields/getbytitle('My Site Column')/SchemaXml

The above end point is called with a GET method resulting in the SchemaXml of the field to be returned

Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online image 25

Create a site column as a list column

By calling /_api/web/lists/getByTitle(‘List Name’)/fields/createfieldasxml with a POST method. You can use a site column

{
                   'parameters': {
                       '__metadata': { 'type': 'SP.XmlSchemaFieldCreationInformation' },
                       'SchemaXml': 'columnSchema
'
                   }
}

We are now ready to use the SchemXml that we retrieved for the field.

In the flow we will need to collect the SchemXml by collecting it from the earlier REST API call.

@{outputs('Send_an_HTTP_request_to_SharePoint_3')?['body/d/SchemaXml']}
Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online an example sharepoion trest api call in power automate

And when we run that the flow will be successful in creating the site column on the list.

Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online image 26

And on the SharePoint list I’ve got my column replicated.

Create a SharePoint list using Power Automate Microsoft Office 365, Microsoft Power Automate, Microsoft SharePoint, Microsoft SharePoint Online image 28
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

32 thoughts on “Create a SharePoint list using Power Automate”
  1. Is there any way to create the list based off a List Template that is already in the List Template Gallery?

    1. I believe that that doesn’t work. The answer is yes for the out of the box list templates but the answer is no fro the list templates that you created with save as list template. There is a problem with the list template ID if I remember that correctly. But then I never liked to use that option anyway.

  2. Hi Pieter, thank you for the great article. Once the list has been created, can Power Automate then add the list to a Sharepoint page as a list web part?

  3. Hi Pieter, thank you for the useful information. Is it possible to use a for-each loop to iterate through the columns in List A, extract the column name and type (e.g. single line of text, multiple lines of text, person, choice, etc.) for each column, and create each of the columns in the newly created List B? I could hard-code each individual column using the “Adding a column to a SharePoint list” method you described above, but this requires future hard-coding if additional columns are added to List A. Thank you in advance for your help.

    1. HI Jonathan, I would consider using an azure function running PnP PowerShell called from a flow. If this was something that you have to do on a regular basis.

      If you want to do this within the flows then you can do that too. Using the various MS Graph/REST API calls.

  4. Hi Pieter, thank you for the useful information. Is it possible to iterate through the columns in List A using a for-each loop and extract the column name and type (e.g. single line of text, choice, person, etc.), in order to add each column in list A to the newly created list B? I could hard-code each individual column using the “Adding a column to a SharePoint list” method described above, however this requires future hard-coding if any new columns were to be added to List A. Thanks in advance for any help you can provide.

    1. @johathan, Did you ever figure this out? I would like find an iterative way to create the multiple columns also.

      1. The rest api/graph api could do this for you. It wouldn’t be straight forward but I would expect that with a bit of research it shouldn’t take long to put this in place.

  5. Hi Pieter,
    very interesting article !
    Here is a question about it:
    can I create multiple columns right away with one HTTP request or do I need a separate one for each column. If several are possible at the same time, how do I have to separate them syntactically?

    Best Regards
    Herb

  6. Hi Pieter, love you articles! Super helpful.
    Is it possible in the same flow to create a list column and then to create a list item using that new column? Thanks

    1. Yes that will be possible. The creation of the list column will be another endpoint to call. A lot here will depend on the type of column etc.

      To create an item is then all quite easily done with yet another graph api or rest api end point.

  7. can any you help me, how to create associate the powerapps with list and publish the powerapps. I already exported the powerapps as zip file. Now I needs to use that zip file and associate with the list automatically once List is created. and publishthe powerapps.

    1. I assume that you are talking about SharePoint Lists.

      The best way is to include your Apps in a solution. Then use an environment variable in your solution to connect to a sharepoint list. Then export and import solutions rather than exporting apps

  8. Hi Peter,
    thanks a lot for this article.
    I want to create a choice column with automate.
    Is it possible to also create the choices for the column using the REST API?

    1. You can use the POST method on the following endpoint:

      /_api/web/lists/GetByTitle(‘My List’)/Fields

      Then in the body you need to supply the field data. For a text field that will look like this:

      { ‘__metadata’: { ‘type’: ‘SP.Field’ }, ‘Title’:'” + folderName + “‘, ‘FieldTypeKind’: 3 }

      https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee540543(v=office.15)

      The FieldTypeKind for Choice fields is 6

      For a choice field it would look something like this:

      {
      “__metadata”: {
      “type”: “SP.FieldChoice”
      },
      “FieldTypeKind”: 6,
      “Title”: “Field name”,
      “Required”: “false”,
      “EnforceUniqueValues”: “false”,
      “StaticName”: “FieldName”,
      “Choices”: { ‘results’: [‘Option 1’, ‘Option 2’, ‘Option 3’] }
      }

  9. I am copying your action precisely but I keep running into this error: Invalid JSON. More than one value was found at the root of the JSON content. JSON content can only have one value at the root level, which is an array, an object or a primitive value.

    I have tried everything I can think of and run a dozen tests. Nothing works! I can’t find any good explanation of this error or what to do about it. Any ideas? Also, what would be the syntax for adding multiple columns in the same action? Just separated by semicolon? I can’t figure out if it’s possible because I can’t get even ONE column created!

    1. Can you copy the json or send me a screenshot on the chat of this site?

      In short it means that you create multiple objects ( things that start with a { and end with a } )

      If you have an array then it will need to start and end with square brackets [ ]

  10. Hi Pieter is there a way to create a list from an uploaded excel file?

    Use case would be as follows:
    1. User uploads excel to sharepoint
    2. Sharepoint list is automatically created from that excel file, with same name
    3. Excel rows populate automatically as list’s items

    I have been having issues with the population of data to the newly created list and also the list always appears as hidden even if I set the Hidden to False.

    Regards 🙂

    1. Hi Caroline,

      If your excel is a table based excel file then you can use the excel connector other wise use this method: https://sharepains.com/2018/10/17/microsoft-flow-read-large-excel-files-within-seconds-without-creating-tables-using-microsoft-graph/

      That should give you the content of the Excel file.

      Then to create a list please have a look at this post:
      https://sharepains.com/2020/09/08/create-sharepoint-list-power-automate/

      then finally to create the data in the list this post might help:
      https://sharepains.com/2021/02/02/create-item-sharepoint-power-automate/

  11. Hello Peter,

    Thank you so much for sharing this, just one question, is it possible to use dynamic content for the name of every new list? I mean every time an item is added, the new list will have different names but when I use dynamic content, I get the following error:

    “An entry without a type name was found, but no expected type was specified. To allow entries without type information, the expected type must also be specified when the model is specified.”

    {
    “AllowContentTypes”: true,
    “BaseTemplate”: 100,
    “ContentTypesEnabled”: true,
    “Description”: “My list description”,
    “Title”: ” ”
    }

    1. Hi Sulem,

      Yes that shouldn’t be a problem. Dynamic content can be used. In your case it looks like the Title field is not set. You might want to check that the Dynamic content used is actually set to a value.

  12. Hi Pieter,

    I used this great tutorial to create the list. In the last step I want to send an email with the URL to newly created list. How can I get that URL?

    Thanks.

    1. Hi Harish,

      The creation of the list doesn’t give you the url of the list. However you could query the site and get all the lists and libraries and filter this by the name of the list that was just created.

      What do you want to do with the url of the list? If you are planning to use it within another API call then you will be getting the list or library back that can be used to then query that library or list.

Leave a Reply to JonathanCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading