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.

Nothing too complicated.

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

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

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.

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.

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 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']}

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

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

Share
Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

View Comments

  • Is there any way to create the list based off a List Template that is already in the List Template Gallery?

    • 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.

  • 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?

    • I would probably do that with an Azure function called from a flow. This function could use PNP PowerShell.

Recent Posts

Calculate the Sum for a SharePoint column in Power Automate

Last week Shane Young asked me about calculating the Sum for a SharePoint column in…

3 hours ago

Object must implement IConvertible in Power Apps

In Power Apps when you do a Patch to create a new item or to…

4 days ago

Get started with adaptive cards in Power Automate

Getting started with adaptive cards can be difficult. In this post i have written some…

1 week ago

Create PDF documents from data in Power Automate

In this post I will look at how to create PDF documents from data. Use…

2 weeks ago

Unnest nested arrays in Power Automate

We all know this problem, you have a nested array in Power Automate but how…

3 weeks ago

Advanced settings not loading in Power Platform

Yesterday one of my clients showed me an issues where the Advanced settings didn't load.…

4 weeks ago
%%footer%%