web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Renaming File with HTT...
Power Automate
Answered

Renaming File with HTTP Request - Handling Existing File with Same Name

(1) ShareShare
ReportReport
Posted on by 62
Hello!
I am uploading documents to a SharePoint Library then renaming them using a "Send HTTP Request to SharePoint" action. However, I am not sure how to handle when a file already exists in that library with the same name most efficiently. Right now, the flow errors out, but ideally the file would just save with a number at the end to differentiate it, the way it does when you create a file in a SharePoint Library with a name that already exists. See attached image for my HTTP request.
 
Any advice is appreciated! Thank you!
Categories:
I have the same question (0)
  • Srini007 Profile Picture
    3,327 Super User 2025 Season 2 on at
     
    Why don't you use Create File and then pass the same filename?
     

    (If this answers your question you can mark as Answered and give it a Like)

    Regards,
    Srini
  • Suggested answer
    Tomac Profile Picture
    3,951 Moderator on at
    This is pretty simple to do - just add a second HTTP action doing the same thing but with a number appended to the name and configure it to only run after the previous HTTP action fails. If the previous action succeeds (the filename was not already in use) then the second action would be skipped:
     
    To use the Configure Run After feature, click the 3 dots on the second action and choose Configure Run After from the menu:
     
    And in this case, you'd select the Has Failed box: 
  • user1093800590384777 Profile Picture
    62 on at
    @Srinivas Kadamati For some reason, if I try to rename the file directly in Create File, the file gets corrupted. The file only saves properly to SharePoint when the name it's uploaded with matches the name in Parse JSON.
  • user1093800590384777 Profile Picture
    62 on at
    @Tomac Thanks for your response! My only concern is what if there is already a file with the number appended at the end as well. I am uploading user submissions so I can't control how many submissions they upload with identical names unfortunately.
     
    My thought was maybe to have a "Do Until" loop that's triggered by the failure of the renaming that waits for the action to succeed to update some variable and append that to the end of the file name, but I was wondering if there was maybe something more simple I was missing.
     
    Let me know what you think - thank you!
  • Verified answer
    Tomac Profile Picture
    3,951 Moderator on at
    Instead of appending a set number, you could append the current timestamp to the filename in the second action: 
    FileName_@{utcNow('yyyy-MM-dd_HHmmss')}
     
     
    Or set that as your standard naming convention and skip the second HTTP action entirely, because the first will always be unique
  • user1093800590384777 Profile Picture
    62 on at
    @Tomac Very creative idea, I'll do that. Thank you!
  • Verified answer
    user1093800590384777 Profile Picture
    62 on at
    @Srinivas Kadamati Thanks again for your response! In regard to my last response to your recommendation, I figured out why I couldn't change the name right from Create Item - I didn't realize I had to put the document type at the end of the name (ex. ".pdf"). That's why the Parse JSON provided name was working - it automatically includes the document type. 
     
    Now that I added ".pdf" to the end of the name, I can rename my file straight from Create Item.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard