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 / When I create a file i...
Power Automate
Unanswered

When I create a file in a SharePoint library - Bad Request - error 400: "A file with the name ...already exists

(0) ShareShare
ReportReport
Posted on by 208

Hello,

 

For an automated flow (trigger:  When a file is created or modified), after the flow creates a document in One Drive and transform it to PDF, I try to create a file in a second library. The second library have the Versioning turn on.

 

If a file already exist in the second library, my flow fails on the action "Create file" with this error Bad Request - error 400: "A file with the name ...already exists.

 

I expected the file to be created and added in the version history of the existing file.

 

I was thinking that, maybe exist the possibility to change the status of the old file or to delete it and then to create the new file.

 

Please do you have any idea how can I fix this problem?

 

Thank you for your kind support

 

 

Categories:
I have the same question (0)
  • Verified answer
    Mark-Shenouda Profile Picture
    Microsoft Employee on at

    Hi @claudia 

     

    This might happen when you use the Create File action, I suggest you consider using "Update File" action incase of error by using try catch mechanism.

    By this way you can create files if they are not existing and update them if they exist 

     

    Hope this helps you in your implementation 

     

    Best Regards 

    Mark 

  • claudia Profile Picture
    208 on at

    Thank you very your prompt reply @Mark-Shenouda 

    I have tried to use the "Update file", but the content of the existing file didn't change. 

     

    First screen shot.JPGSecond screen shot.JPGThird screen shot.JPG4th screen shot.JPG5th screen shot.JPG.

     

  • Mark-Shenouda Profile Picture
    Microsoft Employee on at

    Hi @claudia 

     

    Normally, when you set versioning in SharePoint , Create File will add a new version incase the account has sufficient permissions and the file is not checked out or in-use.

     

    So I suggest you try a simple flow , like moving a file from OneDrive on creation to SharePoint list using the Create File action. Just to make sure that it is overriding the file with newer version. (make sure file is not checked out or in-use )

    If it works well, we can investigate further and build up on it.

     

    Best Regards

    Mark

  • claudia Profile Picture
    208 on at

    @Mark-Shenouda , 

     

    The file is not checked-out or in use.

    Versioning is turn on 

    If I use Create file, then I receive the error: Bad request - 400 - The file already exist........

    If I use Update file, it looks like the flow run successful, but the document content is not updated. In Running history, I could not see what happened with the Update file action because it is in an "Apply to each".

     

    Yesterday I have created a file in my library, this morning I tried to create another file (with same filename but different content) and I saw that I had 2 files in the same library with same filename. 

     

    When I tried to manually upload the file in the library, I was able to overwrite it.

     

    This flow worked fine, until yesterday.

     

    Thank you for your help.

  • Mark-Shenouda Profile Picture
    Microsoft Employee on at

    Hi @claudia 

     

    As I understood from your initial requirement , that you will need to update one file (with its metadata). 

    So the Update file action shouldn't be in the Apply Each loop, you only do the update once. 

    I recommend to apply a small flow scenario to test the override as the Create File action will override and create an new version, just to make sure that the issue is not in the SharePoint list setting.

     

    Would it be possible to apply the below flow on the default Documents list and on you custom Documents list in SharePoint and update me with the results. (You can remove the file and add it again with same name after update to test the override)

     

    Mark-Shenouda_0-1599990576253.png

     

     

    Best Regards 

    Mark 

     

  • claudia Profile Picture
    208 on at

    Hi @Mark-Shenouda 

     

    Thank you for your support!

     

    For the moment, I have fixed it based on your recommendation to use "Update file" (if the document exist in the library) and "Create file" for a new document.

     

    I still don't understand why, the document will not be updated if I use the action "Create file". The filename of the new version is the same as the existing document.

     

     

  • ahmednaseem Profile Picture
    on at

    This is something started recently. Any new create file actions is doing this error. Old ones are still working fine.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard