How to Create Content Type in SharePoint using Power Automate

Site Content types in SharePoint are a collection of Site columns, which we can use in any List and libraries in that SharePoint site and subsites.

In this Power Automate tutorial, we will see how to create content type in SharePoint Online using Power Automate. Also, we will see how we can get the site content type using Power Automate. At last, we will see how to delete a site content type using Power Automate in SharePoint Online.

Here are the topics we are going to cover:

  • Create site content type using Power Automate
  • Get the site content type using Power automate
  • Delete site content type from SharePoint using Power automate

Create site content type using Power Automate

Here we will see how to create site content type in SharePoint using Power Automate.

We will create a site content type named ‘Custom Content type’. Also, we will create a new group or category named as ‘Custom Group’ with a Power Automate Rest API call.

Follow the below steps to create a site content type using Power Automate Rest API.

Step 1: Log in to Power Automate, click on the +Create icon -> select the Instant Cloud Flow.

Create Content Type in SharePoint using Power Automate

Then provide the flow name, and select Manually trigger flow action. Click on Create.

Create sharepoint site content type using power automate

You can see the ‘Manually trigger a flow‘ action is added to the flow.

Power automate create site content type

Step 2: We will create the site content type, so click on the +New step button -> select the ‘Send an HTTP request to SharePoint‘ action. Then provide the below information:

  • Site address: Select or provide the SharePoint site address.
  • Method: Select the method POST as we are creating the site content in SharePoint Online
  • Uri: Provide the below code as Uri:
_api/web/contenttypes
  • Headers: provide the code as a header, it requires for API call:
{
  "Content-Type": "application/json;odata=verbose",
  "Accept": "application/json;odata=verbose"
}
  • Body: Provide the body as the below code, which contains information related to site content type.
{
  "__metadata": {
    "type": "SP.ContentType"
  },
  "Name": "Custom Content Type",
  "Description": "This is a custom content type",
  "Group": "Custom Group"
}
Power automate create sharepoint site content type

Step 3: Our flow is ready, so, click on the Test icon -> select Manually -> click on Test button -> configure the connectors, click on Run flow -> click on Done.

You can see flow ran successfully

Power automate create sharepoint online site content type

Next, navigate to the Site settings -> under Web Designer Galleries -> click on Site content type. Here you can see the site content type named ‘Custom Content Type’.

How to create content type using power automate in sharepoint

This is how to create a site content type in SharePoint Online using Power Automate or Microsoft Flow.

Get SharePoint site content type using Power automate

Here we will see how to get a site content type from SharePoint using Power Automate.

For this, create an Instant cloud flow and select Manually trigger a flow action.  Then add a new action i.e. ‘Send an HTTP request to SharePoint ‘. Provide the below information:

  • Site address: Provide or select the site address for creating site columns.
  • Method: Select the Get method as we are fetching the site content type from the SharePoint site.
  • Uri: Provide the below uri to get the site content Id:
_api/web/contenttypes?$filter=Name eq 'Custom Content Type'

Now run the flow manually, as the site content type is ‘Custom Content Type’ is available, you can check all the information in the output.

Get SharePoint site content type using Power automate

Now run the flow manually, as site content type ‘Custom Content Type’ is available, you can check all the information in the output

Get SharePoint site content types using Power automate

This is how you can check the site content type using Power Automate.

Delete site content type from SharePoint using Power Automate

Here we will see how to delete a SharePoint Online site content type using Power Automate.

In the last flow, we fetch the site content type from the SharePoint Online site. So, in this, we will use the same flow to delete the SharePoint Site content type.

So, now we will get the Site content Id, for this, click on +New step -> select Parse json action. Then provide the below information:

  • Content: Provide the output of the Send an HTTP request to SharePoint(fetch the content type)
  • Schema: To get the schema, click on Generate from sample, then provide the output of the above step. Click on Done.
Delete site content type from SharePoint using Power Automate

Next, click on +New step, and select Compose action. Then provide the below information:

  • Inputs: Select the StringValue -Parse json, from the dynamic content. This will automatically add Apply to each action.

At last, we will delete the Site content type, so, click on Add an action -> then select Send an HTTP request to SharePoint‘ action. Then provide the below information:

  • Site address: Provide or select the site address for creating site columns.
  • Method: Select the Delete method as we are deleting the site content type from the SharePoint site.
  • Uri: Provide the below URI to delete the site content Id:
_api/web/contenttypes('@{outputs('Compose_2')}')
  • Header: provide the below code, required to do rest API call
{
  "Accept": "application/json;odata=verbose"
}
Create site content type in Sharepoint Online using flow

Now run the flow, and you can check the site content type i.e. ‘Custom Content Type’ get deleted from Content type Galleries in SharePoint Online.

This is how to delete a content type from a SharePoint site using Power Automate.

Conclusion

In this Power Automate tutorial, we saw how to create content types in SharePoint using Power Automate.

Also, we saw how to get a SharePoint site content type and delete the site content type from SharePoint using Power Automate.

You may also like:

>