Create SharePoint List and SharePoint document Library in SharePoint site using Power automate

Loading

Requirement: Create SharePoint List and SharePoint document Library in SharePoint site using Send an HTTP Request Action in Power automate

Create Manually Trigger a flow, Add Text as SiteName,ListName,LibraryName.

Add Initialize variable actions, Provide Name: SiteName, ListName, LibraryName and Add another Initialize variable action, which is to add Site URL and Site Name from previous declared variable.

Add an Send an HTTP Request action, Create List for the provided site,

  • Site Address: SiteURL from Initialize variable
  • Method: POST
  • Uri: /_api/web/lists
  • Headers: Enter key-Content-Type , Enter Value-application/json;odata=verbose
Body: 
{
  "__metadata": {
    "type": "SP.List"
  },
  "AllowContentTypes": true,
  "BaseTemplate": 100,
 "ContentTypesEnabled": true,
 "Description": "@{variables('ListName')}description",
 "Title": "@{variables('ListName')}"
}

Add an Send an HTTP Request action, Create Library for the provided site

  • Site Address: SiteURL from Initialize variable
  • Method: POST
  • Uri: /_api/lists
  • Headers: Enter Key-Accept, Enter Value-application/json
Body:
{
  "BaseTemplate": 101,
 "ContentTypesEnabled": true,
 "Description": " @{variables('LibraryName')}description",
 "Title": "@{variables('LibraryName')}"
}

Add Scope action, Add 3 Send an HTTP Request Action to add fields in the list.

  • Field1-
    • Site Address: Site URL(initialize variable) from dynamic content
    • Method: POST
    • Uri: _api/lists/getbytitle(‘ListName(from dynamic content)’)/fields
    • Headers: Enter Key- Content type, Enter value- application/json;odata=verbose
  • Field2-
    • Site Address: Site URL(initialize variable) from dynamic content
    • Method: POST
    • Uri: _api/lists/getbytitle(‘ListName(from dynamic content)’)/fields
    • Headers: Enter Key- Content type, Enter value- application/json;odata=verbose
  • Field3-
    • Site Address: Site URL(initialize variable) from dynamic content
    • Method: POST
    • Uri: _api/lists/getbytitle(‘ListName(from dynamic content)’)/fields
    • Headers: Enter Key- Content type, Enter value- application/json;odata=verbose
Field1- Body:
{
  "__metadata": {
    "type": "SP.Field"
  },
  "Title": "Integer Field",
"FieldTypeKind": 9
}

Field2- Body: 
{
  "__metadata": {
    "type": "SP.Field"
  },
  "Title": "Name Column",
"FieldTypeKind": 2
}

Field3- Body:
{
  "__metadata": {
    "type": "SP.Field"
  },
  "Title": "Currency Column",
"FieldTypeKind": 10
}

Now Save and Run the flow. Add SiteName from Site URL , SharePoint listname, SharePoint libraryname.

Now Check the list and library created in the Site and fields in the list.

Leave a Reply

Your email address will not be published. Required fields are marked *