How To Create Term In Term Store Using Power Automate

Introduction

 
With the introduction of SharePoint V2 REST API for Managed Metadata services, it has become very easy to create a term in term store using REST API. But what if we would like to automate things? In such cases we can use the help of Power Automate.
 
In the automation, we would create a simple custom SharePoint list with only title field, and when a user enters the item in the list we would create a term for that particular title.
 

Steps to be used to create flow using Power Automate

 
Step 1 - Select the trigger (when an item is created)
 
We require this flow to trigger when a new item is created in the list, so we select the trigger as "when an item is created". Once we have selected the trigger we need to select the site collection where the list is present and the list for which we need this trigger to work,
 
How To Create Term In Term Store Using Power Automate
 
Step 2 - Create variables (Initialize variable)
 
We will create two variables with the step named "Initialize variable"
 
Let us set the name of the variables as mentioned below:
  1. GroupId
  2. TermSetId
We will use string as the type of both the variables.
 
We can provide the value as Group Id and TermSet Id.
 
To fetch the Id of group and term set we can navigate to the SharePoint admin center and expand the content service section present in the left navigation and click on Term store.
 
Click on the group under which we need to create the term and copy the "Unique identifier" field value. In the same process for the term set, we can select the term set under which we need to create the term and copy the "Unique identifier" field value.
 
How To Create Term In Term Store Using Power Automate
 
How To Create Term In Term Store Using Power Automate
 
Step 3 - REST API (Send an HTTP request to SharePoint)
 
We will now send the REST API to create the term, for that we will add a step named "Send an HTTP request to SharePoint". This will allow us to use the SharePoint REST API v2 for Managed Metadata service for creating terms.
 
Site Address - We can select the site address from where we need to post the API.
Method - We will Select POST as the method value.
 
Uri
  1. _api/v2.1/termStore/groups/@{variables('GroupId')}/sets/@{variables('TermSetId')}/children   
Note
We will use the groupId and TermSetId variables in the URI.
 
Body
  1. {  
  2.     "labels": [  
  3.         {  
  4.             "name""@{triggerBody()?['Title']}",  
  5.             "isDefault"true,  
  6.             "languageTag""en-US"  
  7.         }  
  8.     ],  
  9.     "descriptions": [  
  10.         {  
  11.             "description""@{triggerBody()?['Title']}",  
  12.             "languageTag""en-US"  
  13.         }  
  14.     ]  
  15. }   
Note
We have used the title as name and description of the term but we can use another field value created in the list as described.
 
How To Create Term In Term Store Using Power Automate
 

Conclusion

 
Term creation is automated by using flow in Power Automate. This can be helpful as most of the users will not have access to term store but they can create an entry in the list and if the user who has created the flow has proper access to create the term, then the terms get created in Term Store.