7 SharePoint API Hacks with Power Automate That Have No Existing Power Automate Actions
While Power Automate offers a wide range of pre-built actions to interact with SharePoint, there are still some advanced functionalities that are not available directly through the standard actions. In these cases, you can extend the capabilities of Power Automate by leveraging SharePoint's REST API. Here are seven hacks that can help you achieve functionalities that have no built-in actions in Power Automate, complete with code examples.
1. Create Document Library with Metadata Fields
While Power Automate allows you to create list items and update them, there’s no native action for creating an entire document library with custom metadata fields. However, with the SharePoint API, this can be automated.
Code Example:
To create a new document library with metadata fields, use the following API call:
Method: POST
Uri:
_api/web/lists
Headers:
Content-Type: application/json;odata=verbose
Body:
{
"__metadata": { "type": "SP.List" },
"AllowContentTypes": true,
"BaseTemplate": 101,
"ContentTypesEnabled": true,
"Title": "NewDocumentLibrary"
}
This creates a document library called "NewDocumentLibrary." You can then extend this by adding columns with another API call to define the metadata fields.
2. Set Unique Permissions for SharePoint Folders
While you can set permissions for lists and libraries using Power Automate’s actions, there is no direct action to break inheritance and assign unique permissions at the folder level. This can be crucial for organizing security in document libraries.
Code Example:
To break permission inheritance for a folder and set unique permissions, use the following code:
Method: POST
Uri:
_api/web/GetFolderByServerRelativeUrl('/Shared Documents/YourFolderName')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=false, clearSubscopes=true)
Headers:
Accept: application/json;odata=verbose
This breaks the inheritance for the folder "YourFolderName" in the "Shared Documents" library, allowing you to assign unique permissions.
3. Batch Create Multiple SharePoint List Items in One Request
In scenarios where you need to create multiple SharePoint list items quickly, Power Automate doesn’t provide a way to perform bulk inserts. However, using the SharePoint API, you can leverage batch requests to speed up this process.
Code Example:
To create multiple list items in a single request, you can use a batch API request like this:
POST https://yourdomain.sharepoint.com/_api/$batch
Content-Type: multipart/mixed; boundary=batch_12345
--batch_12345
Content-Type: application/http
Content-Transfer-Encoding: binary
POST /_api/web/lists/getbytitle('Tasks')/items
Content-Type: application/json;odata=verbose
{
"__metadata": { "type": "SP.Data.TasksListItem" },
"Title": "Task 1"
}
--batch_12345
Content-Type: application/http
Content-Transfer-Encoding: binary
POST /_api/web/lists/getbytitle('Tasks')/items
Content-Type: application/json;odata=verbose
{
"__metadata": { "type": "SP.Data.TasksListItem" },
"Title": "Task 2"
}
--batch_12345--
This will create two new tasks ("Task 1" and "Task 2") in the "Tasks" list in a single API call, saving time and resources.
4. Retrieve and Apply a SharePoint Template to a List
There is no Power Automate action to apply a SharePoint list template (or a site template) programmatically. This is useful for creating uniform lists or libraries across multiple sites.
Code Example:
To apply a list template via SharePoint API, you can use this call:
Method: POST
Uri:
_api/web/lists/getbytitle('TemplateList')/reusetemplate
Headers:
Content-Type: application/json;odata=verbose
Body:
领英推荐
{
"__metadata": { "type": "SP.ListTemplate" },
"ListTemplateName": "CustomTemplate"
}
This call will apply a predefined template ("CustomTemplate") to create a new list similar to the "TemplateList."
5. Change the Welcome Page of a SharePoint Site
Power Automate lacks the functionality to update the home (welcome) page of a SharePoint site. However, this is a common requirement when deploying custom pages and needing to set them as the default home page for a site.
Code Example:
To set a custom page as the welcome page, use this API call:
Method: POST
Uri:
_api/web
Headers:
Content-Type: application/json;odata=verbose
Body:
{
"__metadata": { "type": "SP.Web" },
"WelcomePage": "/sites/yourSite/SitePages/CustomHome.aspx"
}
This sets the page CustomHome.aspx as the welcome page for the SharePoint site.
6. Move SharePoint Files Between Sites
Power Automate has native actions to copy files within a SharePoint site, but moving files between different SharePoint sites requires using the SharePoint REST API. This is especially useful for archiving files or transferring them to other departments.
Code Example:
Here’s how you can move a file between two SharePoint sites using the REST API:
Method: POST
Uri:
_api/web/GetFileByServerRelativeUrl('/sites/sourceSite/Shared Documents/file.txt')/moveto(newurl='/sites/destinationSite/Shared Documents/file.txt',flags=1)
Headers:
Content-Type: application/json;odata=verbose
This moves "file.txt" from the source site to the destination site.
7. Create SharePoint Subsites Programmatically
Power Automate doesn’t have an action to create subsites within SharePoint sites, which can be useful for automating the provisioning of new sites for departments, projects, or teams. However, this functionality can be achieved through the SharePoint API.
Code Example:
To create a subsite using the SharePoint REST API, use the following request:
Method: POST
Uri:
_api/web/webinfos/add
Headers:
Content-Type: application/json;odata=verbose
Body:
{
"parameters": {
"__metadata": { "type": "SP.WebInfoCreationInformation" },
"Title": "New Subsite",
"Url": "newsubsite",
"Description": "This is a new subsite.",
"Language": 1033,
"WebTemplate": "STS#0",
"UseUniquePermissions": true
}
}
This creates a new subsite called "New Subsite" with unique permissions under the current SharePoint site.
These SharePoint API hacks offer a glimpse into the more advanced capabilities you can unlock when automating tasks with Power Automate. By using the SharePoint REST API, you can extend your workflows beyond the limitations of built-in actions and achieve tasks like creating subsites, managing permissions, and bulk item updates—all without manual intervention.
Feel free to experiment with these API calls and integrate them into your Power Automate flows to enhance your SharePoint automation.
RPA Developer
3 周Great. Is possible to insert multiple rows in a SharePoint List from Excel using this method? or How can I reduce the time to insert rows in a SharePoint list?
Assoc. Consultant | RPA Developer | Xceptor | Microsoft Power Platform | Python
3 周The batch create list items looks a bit different from Paul's post. It has a batch ID and the individual items are enclosed within a changeset id. I'll give this a try. Thanks
Solutions Architect | YouTuber | Team Lead | Microsoft MVP
3 周This is a great list! In fact, someone was asking about this so I'll forward it. Another one I like is the "search" endpoint for querying on site names.
Connecting Enterprises with M365 Workplace & SharePoint Solutions
3 周Love a good hack, thank you for sharing Marcel Broschk
Empowering Teams to Work Smarter with Microsoft 365 ? Flexible Consultancy for Optimal Operations ? Microsoft MVP with 20+ Years Experience
3 周I really like this one I already did now them but still that you connect it to Powerautomate is great solution for many people