Power Automate to Copy and Move Document sets using REST

Power Automate to Copy and Move Document sets using REST header image

Within the same project as my last blog on Power Automate & OData Queries we had to copy some content. Besides sending notifications in some cases we had to copy a document set to a separate library. This copy action had to capture the status of the document set. This of course had to happen using the correct metadata and all files placed in the document set.

Copy a document set

There is no action available in Power Automate to do this by default. There is the Copy File or Copy Folder, but the copy folder did not supply the solution we were looking for. In most scenario’s the Copy Folder should work as pointed out at the PowerUsers forum. In our case we choose not to spend to much time on figuring out what limitation we hit. We just worked around it using the SharePoint REST action. Using the SharePoint rest action, you can use the REST CreateCopyJobs.A nice write up on how to use the API can be found on The CreateCopyJobs API, copy or move SharePoint files or folders. So the copy action is straight forward:

  • A post to the correct API
  • A body with some settings
    • The folder that we want to copy
    • The library to copy to
    • The settings we want to copy with

Once you have decided on those settings all you need is the SharePoint REST action. Set the site address to the correct site collection. Then set the method to POST and the URI to /_api/site/CreateCopyJobs and set the body:

{
   "exportObjectUris":[
      "@{variables('siteUrl')}/Lists/Library1/@{items('Iteration')?['{Name}']}"
   ],
   "destinationUri":"@{variables('siteUrl')}/Lists/Library1",
   "options":{
      "IgnoreVersionHistory":true,
      "IsMoveMode":false
   }
}

Making the full action look as follows:

Power Automation REST action

Executing the POST request will return a 200 status if all is correct. The body of that status, if required you can use the /_api/site/GetCopyJobProgress to check the status. You can even poll the status until it has the JobStatus 0 so you know the copy was successful before proceeding to the next action.

Loading comments…