Power Automate: Update File Name of SharePoint Document on File Upload using HTTP Action

Problem Statement

When we upload a document to SharePoint and has to rename it as soon as it is uploaded, there is no straight forward way to do it using Update action. 

Solution

We can use the HTTP Action to update the FileLeafRef attribute of the file

Create the Flow

Lets add the When a file is created trigger action to invoke the flow whenever a file is uploaded to SharePoint

We will be appending the current date to the file name as soon as it is uploaded. To do this create a variable and add append the current date to it using the expression : formatDateTime(utcNow(),'yyyy-MM-dd')

Before we add the HTTP Action, we need to get the ListItemEntityTypeFull name which can be obtained using the below URL. Ensure to update the URL with your environment specific values

https://yoursite/_api/web/lists/getbytitle('List Name')?$select=ListItemEntityTypeFullName

Now lets add the HTTP Action and update the Header and Body of the action as below :

Test the Process

Now lets test the implementation by uploading a file with the name RevenueForMarch and see if the file name gets updated and appended with the upload date as well.

Now lets head over to the Power Automate page and see if the flow has run

The flow was run successfully and has updated the file name in SharePoint as well :

Summary

Thus we saw how to update the file name of a document as soon as it is uploaded to SharePoint using HTTP Action in Power Automate