Microsoft Flow - Renaming Files in SharePoint Online using Flow

So your looking to use Flow and rename some files in SharePoint.

Too easy, but wait - there are no actions available to allow a rename? So what's next!?

Well here we go, REST API to the rescue! But not so fast, there are some catches.

You create a "Sent an HTTP request to SharePoint" action and fill in the properties as follows

Site Address =
Uri = _api/web/lists/getbytitle('<LIST NAME>')/getItemByStringId('<List Item ID>')
Headers =
"X-HTTP-Method": "PATCH",
"If-Match": "*",
"Content-Type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose"
Body =
{'__metadata': {'type': 'SP.Data.Project_x0020_DocumentsItem'}, 'Title':'test', 'FileLeafRef':'test.bmp'}

The above can be created in the activity pretty much like for like.

But you will need to confirm your 'type' specific to your list as generated by SharePoint.

The best way to do this is to download the json file generated by a 'get'.

Basically create an item in your list or library, then access it with a browser to download the JSON file e.g.'<LIST NAME>')/getItemByStringId('<List Item ID>')

Make sure that the List Item ID is for a file you uploaded (you can modify the list view to show the ID column).

Once you download your JSON file open it up in notepad or VIM and search for "SP.Data" you will find the correct name of your type - this is required to update the list item or document correctly.

That's it! Rename your documents using flow.


Popular posts from this blog

Change Password in Windows Server 2012

Using WinDBG to Debug SharePoint & Cheatsheet

NeuroPower Framework to Effective Leadership