I was trying to using MS365 For each file or folder activity but showing share access denied even though sharepoint can be read or edit from browser

Hi,

I was trying to use MS365 For each file or folder activity but showing share access denied even though SharePoint can be read or edit from browser, paths have been correctly provided and only for this particular activity its showing error, for the activity find files and folders its working well but since drive item is restricted to only 200, I have to use MS365 For each file or folder activity. Please share if anyone has addressed this similar issue while SharePoint automation. Thank You!!

Please find the error message

For Each file or folder: Code: accessDenied
Message: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
Inner error:
Code: sharesAccessDenied
ClientRequestId: 4e865cb1-4dfd-4f06-fds98-9458a33e754a
AdditionalData:
@onedrive.linkFeatures:

@Rakesh_Ravinathan_Beena Welcome to community!!

That means still you don’t have the access.
try to follow below thread

Thank you so much for your reply, but my other query was with the same SharePoint link and Application Secret Id, I was able to use Find Files and Folder activity, and it provided me 200 drive items of the same subfolder. Does Permission vary from activity to activity.

Do you have read and write permission for this, if not ask your admin to provide below permissions, then try once

  • Sites.Read.All
  • Sites.ReadWrite.All
  • Files.Read.All
  • Files.ReadWrite.All

Thanks a Lot, will check these permissions with admin.

1 Like

@Rakesh_Ravinathan_Beena

No, the permission doesn’t vary from activity to activity.

If you are able to get response using find and folders and trying the same thing using for each file/folder, it should work too.

Are you please able to show the configuration for each file/folder activity?

@sonaliaggarwal47

Yes, that was my understanding it does not vary from activity to activity, but still i have given for review to my admin to recheck if permissions are missing. Sure, please see the configuration of the activity and let me know if i need to correct. Thank You!!

UiPath_VBS_Word_KanjiToKana.zip (1.8 KB)

Hi @Rakesh_Ravinathan_Beena

Thanks for sharing screenshot.

One thing I noticed there, subfolders are not searched when using app id and secret to connect to M365 app. Only simple search works.

My guess is, issue is with your search query.

Additionally, for test purposes to confirm your permissions, can you try giving specific url where you want to do search instead of site url?

or remove search query and simply run and see if you see the folder you are trying to search in the results.

These tests will narrow down the issue.

Hi @sonaliaggarwal47

Thank you so much I tried what you have suggested, and it is working with specific url and I am able to retrieve the drive item using the specific url. But the issue with specific url is my folder names are dynamic and i have to check different subfolders. So, when i copying specific URL from my Browers it is giving values for me, but creating URL by myself seems not working because SharePoint URL which we copy browser is different with what we create for example

Specific Url which we copy from browser is like:
https://temp.sharepoint.com/tms/FG0061-46712/Shared%20Documents/form%20Subfolder1/Subfolder2

But when i create manually as like below just by giving just folder names it’s not working.

https://temp.sharepoint.com/tms/FG0061-46712/Documents/Subfolder1/Subfolder2

Thank You once again, that simple query search was the issue.

1 Like

Hi @Rakesh_Ravinathan_Beena

Specific url needs to be used as it is, with % and all. It uses internal names rather than display names.

If you are trying specific url for another subfolder.

First navigate and fetch its specific url and check.

If only folder name is different from the current working specific url then you only parameterize that part and rest everything remains same.

Hello I have a similar problem i have no probleme with the find file or folder but i have an acces denied for the for each file.I want to switch since apparently the activity finis obsolete after 2.7.21
Here a screenshot, the main difference with @Rakesh_Ravinathan_Beena is that i use certifact to autentify. I don’t use account Id since it work without it for find file and i don’t really understand what id is needed for this parameter


Hi @Julien_SERRES

Id refers to your O365 tenant here.

For your access denied issue, lets try with minimal queries in there.. Most likely folders you are trying to search is not available at the path you have provided. Please note that simple search doesn;t work on subfolders, only immediate folders list.

And you can’t use advanced search functionality with auth method as app id and secret.

Hi @Rakesh_Ravinathan_Beena

This error happens because the MS365 “For Each File or Folder” activity uses Microsoft Graph API, which requires stricter permissions than browser access.

  1. Make sure the account in MS365 Scope has Sites.Read.All or Sites.ReadWrite.All in Azure AD.
  2. Use the correct DriveItem path, e.g., /Shared Documents/FolderName, not the full site URL.
  3. Check folder permissions; some may block Graph API even if browser access works.
  4. For large folders, the activity may fail due to Graph API limits.

A workaround is to use Find Files and Folders to get the list, then iterate with a standard For Each loop.