SharePoint REST API batching has certain rules that you should be aware of before restructuring your workflow.
When you make a batch request, the items that you are asking to be done will be done in the order that you specified. Yes, SharePoint does care about the order, but you have to understand the concept of "changesets" properly to make it work.
You need to understand that there is a difference between independent requests and dependent requests. Independent requests will be executed in parallel by default. Dependent requests, however, need to be inside a "changeset." This will make them sequential, not parallel. In your workflow, Copy Template, Rename, Break Inheritance, Assign Permissions, Publish, Disable Comments, all of these actions depend on the previous one having been done. You will need one "changeset" that contains all of the actions.
What will batch properly:
Rename the page (PATCH the ListItem) with all the other properties. Breaking permissions inheritance, assigning permissions. Publishing, disabling comments.
What will not batch properly:
- So, if you're using the Copy Template step, you're going to get a new page URL and ID, which you're going to need to use for the next request. The catch here is that you can't use the new ID in the same batch request. This is just one of the rules you need to follow.
- So, to make this whole process more efficient, you should consider keeping the Copy Template as a separate request. This way, you can get the new page ID from the request. Then, you can group all the other steps, such as renaming, breaking inheritance, setting permissions, publishing, disabling comments, etc., as a separate request using a changeset as part of a $batch request.
- So, you're going to end up reducing the number of separate requests from six to just two. This can really help you streamline the process, making it more effective for you.
Just one more thing, the batch endpoint for SharePoint Online should be `_api/$batch`, which follows the OData v3 multipart/mixed request body. Unfortunately, there's no native batch support in Power Automate, so you need to create the raw request body manually using the HTTP request action.
Thank you!
Proud to be a Super User!
📩 Need more help?
✔️ Don’t forget to Accept as Solution if this guidance worked for you.
💛 Your Like motivates me to keep helping