When I try to delete an Excel file I get an error:
"The resource you are attempting to access is locked"
The Excel file can be deleted after 7 minutes but I have found a solution here:
It is possible to call the following API
_api/web/Lists/GetByTitle('DocLib')/GetItemById(ID)/recycle
and unlock the file located on One Drive?
I tried to use it but this API needs a "document library" parameter
which I do not understand (I'm a total beginner with Microsoft Power Automate)
Do you think it is possible to use this API to unlock the file that is located
on my One Drive?
My One Drive files can be listed using the following URL
https://ZZZZ-my.sharepoint.com/personal/UUUU/_layouts/15/onedrive.aspx
ZZZZZ is my compnay name
UUUUU is my user name
What is the DocLib parameter I should use?
Kind regards,
Mark
If you look in the lower left-hand corner while in the document library in OneDrive you should see a link to return to classic OneDrive. If you lick on that you should see the document library name included in the URL. Normally it would be Documents. Something like this
Thank you
Can I retrieve the item ID from the documentURL? How this ID looks like?
With this call:
_api/web/Lists/GetByTitle('Documents')/GetItemById('1F9Y48R4-BX3G-4D32-12XC-76F8D1126F5')/recycle
I get the folIowing error:
"Input string was not in a correct format"
Thank you for your help,
Mark
That's the document GUID. The Item ID its looking for is the SharePoint Integer ID for the item in the document library. How are you retrieving the document metadata? The ID should be included.
With this API i need to unlock the file that was created using the "Create File" action.
"Create File" action returns among other parameters:
Id (a very long string)
Name
Path
Media type
ETag
File locator
From my tests it looks like the parameter I'm looking for is the integer number
When I put an integer number (for example 6)
_api/web/Lists/GetByTitle('Documents')/GetItemById(6)/recycle
... the http request does not return an error. But how can I get this ID number?
Thank you,
Mark
With this API i need to unlock the file that was created using the "Create File" action.
"Create File" action returns among other parameters:
Id (a very long string)
Name
Path
Media type
ETag
File locator
From my tests it looks like the parameter I'm looking for is the integer number
When I put an integer number (for example 6)
_api/web/Lists/GetByTitle('Documents')/GetItemById(6)/recycle
... the http request does not return an error. But how can I get this ID number?
Thank you,
Mark
Unfortunately, the OneDrive Create File action doesn't return the ID you need. But if you use the SharePoint Create File and paste in the Site name of the OneDrive you can create the file and it will return the ItemID, which is the number you need.
Thank you,
But are you sure that SharePoint Create File also returns the ID that is returned by the OneDrive Create File action? In my opinion SharePoint Create File returns the ID that I need to the further Sharepoint API but I don't get the ID that is returned by the OneDrive Create File (which I also need).
Anyway, I managed to convert the ID that is returned by the OneDrive Create File into the ID that is returned by the SharePoint Create File. I will post here the solution soon.
Thank you,
Mark
I tested it and yes, creating a OneDrive file using the Create a File from the SharePoint connector does work to create the file and does return the itemID that you need. Behind the scenes OneDrive is SharePoint so the connector will work for both. The ItemID is the List Item ID that is assigned to the file. You still also get the file identifier which you'll need for file operations. But the REST call you are making operates at the list level, so it needs the list ID, not the file identifier.
Thank you,
I took SharePoint Create File and created a file successfully. The action returned the following parameters:
ItemId (what I was looking for from the beginning)
Id
Name
DisplayName
Path
LastModified
Size
MediaType
IsFolder
ETag
FileLocator (with subparameters dataset and id)
Then I called Delete File action for each returned parameter. None of the parameters let me deletes the file.
The most promising was FileLocator/id but it also fails.
For each parameter I get the message "The file id XXX is not valid"
I examed the file I had created with the Get file metada action and the ID that was returned
does not match with any parameter that was returned by the SharePoint Create File action.
Thank you,
Mark
Please past the final solution/image of the action you have compiled.
Thanks
I have managed to delete a file in OneDrive using SharePoint API
So add "Send a HTTP request to SharePoint"
Site address: put here the address you see in your task bar when browsing your OneDrive, for instance:
https:// .... .sharepoint.com/personal/ .......
Method: POST
URI: _api/web/Lists/GetByTitle('Documents')/GetItemById( variables('sSharePointId') )/recycle
variables('sSharePointId') - I get this variable in my previous step using GetSharePointFile service
Headers: key:Prefer, value: bypass-shared-lock
Let me know if this was helpful.
Regards,
Mark
Hi and thank you but i don't have the id for
GetItemById( variables('sSharePointId')
where i find it?
If you know a file's name and you want to get it's SharePoint ID you must call GetSharePointFile service
Site addess: same as previous ( https:// .... .sharepoint.com/personal/ ....... )
Method: GET
URI: _api/web/GetFileByServerRelativeUrl('/personal/ ....... /Documents/ {variables('sFileName')}')/listItemAllFields?$select=Id
Header: Key = Accept, Headers: application/json;odata=nometadata
And in the next step put the value that is returned from this service into sSharePointId (using SetVariable service)
Good luck
Don't work or i don't understand it correct...i sent you a private message yesterday...
Let's start from the beginning. I assume you have a file on your OneDrive that you want to delete. Is this correct?
yes that's right, I save the excel file to run an automate excel script. after execution I have to send this file by email and then delete it so that next time I can start the run again. This script unfortunately blocks the deletion. last year I managed to get it working, then something happened and now it no longer works.
Can you fetch the SharePoint ID of this file using SharePoint HTTP request?
Disable your second HTTP request, let's focus on the first one.
Instead of {variables('ERD_LISTA_LANCI.xlsx')} put only ERD_LISTA_LANCI.xlsx
Then check if this request returns the file ID
@LaurensM is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024. Consistent Engagement: He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges. Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone. Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community. Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community! Keep up the fantastic work!
We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience! Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up? Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen. Don't miss your moment--start submitting in the Copilot Cookbook Gallery today! Thank you, Engagement Team
We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps. Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community. We can't wait to see what you "cook" up!
You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun. Now that you are a member, you can enjoy the following resources: Welcome to the Community News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate. Be sure to subscribe to this board and not miss an announcement. Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows. You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook. Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today. Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome. Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together. Power Automate Community Team
Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp
It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community. As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn! Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report. Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone. Thank you for helping us keep the community clean and useful!
User | Count |
---|---|
61 | |
34 | |
31 | |
21 | |
11 |
User | Count |
---|---|
91 | |
44 | |
36 | |
26 | |
20 |