Last Updated:
Short notes on how rename a SharePoint folder or file using the SharePoint REST API.
1. How to Rename a Folder 📁
In the example below I have a document library called “Another Demo Library”. There is a folder called “This is the folder” which has the item ID of 72 that I want to rename. The flow will rename this folder (item ID 72) to “Renamed Folder”:

Here is the code used in the API request using the POST action:
USAGE
Method: POST
Uri:
_api/web/lists/GetbyTitle('<Document Library Name'>)/items(<item-ID>)/validateUpdateListItem
Body:
{
"formValues": [
{
"FieldName": "FileLeafRef",
"FieldValue": "<new-folder-name>"
}
]
}
Here is the example code for the API request using the POST action:
_api/web/lists/GetbyTitle('Another Demo Library')/items(72)/validateUpdateListItem { "formValues": [ { "FieldName": "FileLeafRef", "FieldValue": "Renamed Folder" } ] }
And here is the HTTP request used in the flow:

Here is the folder being renamed to “Renamed Folder”

2. How to Rename a File 📄
Here is one method to rename a file in three steps:
- Check Out file
- Rename the File
- Check In the File
You can also simply rename the file without using the Check In and Check Out actions. You’ll see this in Example 2: Renaming a File.
How does it work using the Check In and Check Out actions?

We can use the SharePoint item ID to check-out the file, rename the file and then check-in the file.

USAGE
Method: POST
Uri:
_api/web/lists/GetbyTitle('<Document Library Name'>)/items(<item ID>)/validateUpdateListItem
Body:
{
"formValues": [
{
"FieldName": "FileLeafRef",
"FieldValue": "<filename>"
}
]
}
_api/web/lists/GetbyTitle('Documents')/items(8)/validateUpdateListItem Body: { "formValues": [ { "FieldName": "FileLeafRef", "FieldValue": "TEST123ABC.docx" } ] }
Example 1: Renaming a File with Check In and Check Out actions


In this step I want to save the file to OneDrive before it gets renamed:




Sample runtime output:

Example 2: Renaming a File
You may also be able to simply rename the file without using document version control (Check-Out, Check-In):

For Further reading
For various other ways to rename a file using Power Automate, see the following post: Power Automate Rename File
Leave a Reply