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 / OneDrive: DeleteFile d...
Power Automate
Unanswered

OneDrive: DeleteFile does not work with ID

(0) ShareShare
ReportReport
Posted on by 4
Hello there,
 
i am trying to set up a PowerAutomate flow to periodically clear a few directories in my onedrive that grow over time with log files. OneDrive offers a "Delete file" action (OneDrive - Connectors | Microsoft Learn) with a file id parameter. I get a file id from the previous "ListFolderV2" action (OneDrive - Connectors | Microsoft Learn) but i end up with error 400. Is this the wrong approach or is the documentation not updated? Details below:
 
First i try to list the subfolders of the folder i want to be cleared. this works fine:
 
 
Then i do a loop and go throw each subfolder to list the files. This does work too so far:
 
I get the files with names and IDs. I then do a loop for the files, process the json and throw the file id into the DeleteFile action. This does not work:
The message translated says "The file id XXX is invalid.".
 
I dont understand the issue here. It is clearly the id of the file. Am i missing somthing here?
 
And on a side note: what is wrong with the Categories-field when creating a question. I can't select "Connectors"...
Categories:
I have the same question (0)
  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at
    The Delete file action requires you to insert the Id dynamic content. The ID should be a lot longer than what appears in your screenshot.

    It's hard to offer any recommendations without seeing your full flow and the logic behind it. Toggle off the New Designer and click each action to expand it. Upload a screenshot of your flow in edit mode.



    In the meantime, you might be interested in this YT Tutorial:


    In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:
    1️⃣ Looping through a Single Item
    2️⃣ Creating Unnecessary Nested Loops
    3️⃣ Looping through an Unfiltered Array

    At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.

    IN THIS VIDEO:
    ✓ How to avoid the Apply to Each action with a single item array
    ✓ How to use the item() function to access dynamic content in an array
    ✓ How to prevent unnecessary nested Apply to Each action loops
    ✓ How to use the Select action
    ✓ How to convert an array to a string with the Select action
    ✓How to use the Filter Query field
    ✓ How to count the number of items in an array
    ✓ How to use a condition control
    ✓ How to use the concurrency control
    ✓ How to set a top count
    ✓ How to use Compose actions for troubleshooting

    Hope this helps!

    Consider giving me a ❤️ if you liked my response!

    👉 Level up your Power Automate skills by checking out my tutorials on YouTube
    👉 Tips and Tricks on TikTok and Instagram
  • Johannes Profile Picture
    4 on at
    I rebuilt CreativeOpinions simple example but this throws the same error:
     
     
  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at
    Can you click on the Get file metadata action from your last flow run and compare the Id output to the Id being displayed in the Delete File action?

     
    Your Id doesn't look correct to me. One more thing you can check is the expression of the Id dynamic content. It should look like this.
  • Johannes Profile Picture
    4 on at
    Now i see what you mean, looks a bit shorter in my onedrive.
     
     
    It seems the ids of the files in my onedrive are bad somehow... i'll delete the files manually now

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

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard