I am trying to rename a file in a document library on SharePoint Online, I want that when a user upload a file, a flow change it name, adding the current date and hour. I am not know the formula to add the date at the name of the file, can help me please whit information about that. Is important too that when the user upload a new document the flow don't generate a new version on the historical version document.
Im am trying whit sharepoint designer because I don't know how to create a flow in Microsoft Flows, thanks fot your helps.
Solved! Go to Solution.
Hope someone can help since there is clearly something I'm missing. I've followed the steps in the flows but when I do a test the workflow keeps running until it times out. When I look at what's happened I get a Bad Gateway error.
My flow looks like this
When I combine the site address with the uri, I can view the item's contents without any problems. Have I mistyped or omitted something?
Hi @faustocapellanj ,
I've tried to follow this post about renaming my file in SharePoint. It's been really helpful, but I'm getting the following error message:
Here is why I have:
When I use your recommended _api/web/lists/GetByTitle('List or Doc Library Name here').
My 'List of Doc Library Name' is 'Documents' and it returns 'SP.Data.Shared_x0020DocumentsItem'
I've tried using 'Documents' , 'SharedDocuments' and 'Shared_x0020Documents' instead of 'Shared%20Documents' but still getting the same error message. I wonder if you have an idea on how to get this to work?
I think your issue is that you are using the File Identifier instead of the ID property. If you look at the screenshot below, the section inside the red rectangle is expecting a number not a string.
Try that and let me know.
I have a Folder inside my List. Anyone know how to call that folder instead of the root of the list?
And no response from the API. Error I get is
List 'Documents/General' does not exist at site with URL 'https://
@faustocapellanj any thoughts?
I think for your case, you'll have to use the GetFolderByServerRelativeUrl endpoint. The link below has done information about this endpoint. By the way, I'd test the endpoint in the browser first to make sure you can see the folder you need and then try it in Power Automate.
I followed the instructions carefully but the file name is still the original file name, not updated.
Got an error The parameter __metadata does not exist in method GetById. double underline before metadata, single quote in the json body
Looking at the screenshot you posted, the Uri parameter is missing something: web. Your Uri value is _api/lists/GetByTitle('Document Request')/Items(ID), but it should be _api/lists/web/GetByTitle('Document Request')/Items(ID). Please update it to match the one I posted and give it a try.
The flow finished successfully but the name not updated, name should be: EMS_Environment_Matrix-Restricted-WMF-062220-147.xls.
by the way, I didn't use web in the other URIs to set permission but no issue
_api/lists/getByTitle('Document Request')/Items(insertIDhere)/roleassignments/addroleassignment(principalid=varRequesterID, roledefid=1073741827)
Hi @faustocapellanj ,
I followed your advice, and was able to get to a point where the HTTP Request identifies the file, no problem, but because I have a nested folder structure, I don't know what to input for SP.Data.LISTNAMEItem in the __metadata call.
Using just the very last folder name SP.Data.CHILDFOLDERItem results in this, but any combination of folders doesn't work.
@faustocapellanj this is brilliant! It works great.
Now mine has a wrinkle. My trigger is when someone uploads and then modifies the file, and selects from a drop-down of values in a choice field.
One of the choices is "External Reviewer". There could be several tagged with this. The first file that runs the workflow works great, the second one doesn't, because it says the file already exists.
Anything to handle a duplicate file name with this action, like putting a 1 or 2 at the end of the file name when there are duplicates?
Can you please post a screenshot of the SharePoint HTTP action to see how it is configured? I can't tell exactly what's going on from that error message.
You can try to overwrite the file, but you will need the SharePoint HTTP action. For this one, you set your Site Address and set the Method to POST. For the URI, you can do something like this:
_api/web/GetFolderByServerRelativeUrl('document library name/folder')/Files/add(url='/folder/file.ext', overwrite=true)
Set the Headers to the following Key/Value:
And finally, set the Body to the file content. Please try that and let me know.
I would like to say that I'm stunned that we are still here in 2021 and there is STILL no inbuilt way to rename a file from Power Automate without resorting to raw HTTP REST calls.
But I am totally not surprised. WTF?
I spent a lot of time trying to get it working for me. I needed to use uri functions, as I had "%20" for space in my file link. I was getting the file link from excel(inserted by forms file upload). I am sharing it in case someone finds in useful.
Exactly. Why on earth would anyone EVER want to rename a file???? Sure, Title is one thing but we can change a file name in SharePoint, PowerApps you need to perform yet another msft hack/workaround just to do something THAT SHOULD BE NORMAL, EVERYDAY FUNCTIONALITY. So yes, WTF???!!!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.