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 to Sharepoint...
Power Automate
Unanswered

OneDrive to Sharepoint - Doesn't copy to subfolders

(0) ShareShare
ReportReport
Posted on by 24

I want to create a flow that copies files that have been added to OneDrive for Business to Sharepoint. I have a specific folder structure in OneDrive that has been replicated to the SharePoint site.  Here is what I currently have. Shelbyville.jpg

It works, almost. When I place new file in a sub-folder (for example:  "Shelbyville Church of God/Finance") the flow recognizes a new file was added, but the file is copied to the Shared Documents folder on the SharePoint, instead of into "Shared Documents/Finance" . I have tried to add dynamic content to get the file to land in the correct place, but if I use anything other than "Shared Folder" in the folder path, I get errors that the file could not be created. 

 

Does anyone have any suggestions or guidance? 

Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    hi @PowerAutoSwain  that's because you have added the Folder Path as static value. What you need to do is add a dynamic value, that could the the path from onedrive.

  • PowerAutoSwain Profile Picture
    24 on at

    That doesn't work either. When I put in the dynamic content "folder path", I get an error: "root folder not found".

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    hi @PowerAutoSwain  compare the paths and see what are the correct path.

     

    Some times the dynamic content have more details than needed.

     

    Example of dynamic content: /SharedLibrary/Folder/Folder

    And in action you dont neer the /SharedLibrary/

     

    So what you can do is get just the path you need by using expressions like Substring

  • PowerAutoSwain Profile Picture
    24 on at

    Well, I have just about given up. Something this basic shouldn't be this hard to do. 

     

    If I use only /Shared Folder the file created in a sub-folder is recognized but is created at the Shared Folder level and is visible on the SharePoint site. If I try to use Dynamic File Path, it fails. I tried to select the Shared Folder, then add file path. The error indicated "Cannot create folder "sites/ShelbyvilleChurchofGod/Shared Documents/drives/b!JbBJewNaLU61BPdPOMyZnPWtQJpxlZpAkdcZqjunFksFnABH0ysCRJfP7Xv8o2P4/root:"." As you ccan see, it tries to put in the drives first. By the way, it also creates the "drives" folder just under the Shared Folder on the SharePoint. There is no "substring" function available. Besides, the raw data has an encrypted string that represents the file. There is no way that I can see to parse it to cut off the "Shared Folder" from the beginnng of the string.

  • PowerAutoSwain Profile Picture
    24 on at

    I found a substring action, so i inserted it between the trigger and the action. Since the file path is "/Shared Documents", I configured the substring to trim the first 17 characters. Here is what I got:

     

    Raw Input
    {
    "text": "L2RyaXZlcy9iIUpiQkpld05hTFU2MUJQZFBPTXlablBXdFFKcHhsWnBBa2RjWnFqdW5Ga3NGbkFCSDB5c0NSSmZQN1h2OG8yUDQvcm9vdDovU2hhcmVkIHdpdGggRXZlcnlvbmUvUHJvamVjdHMvU2hlbGJ5dmlsbGVDaHVyY2hvZkdvZC9TaGFyZWREb2N1bWVudHMvMDEtUHJvamVjdCBEZWZpbml0aW9uL015RmlsZS50eHQ=",
    "startingPosition": 17
    }

    Raw Output

    "body": "kpld05hTFU2MUJQZFBPTXlablBXdFFKcHhsWnBBa2RjWnFqdW5Ga3NGbkFCSDB5c0NSSmZQN1h2OG8yUDQvcm9vdDovU2hhcmVkIHdpdGggRXZlcnlvbmUvUHJvamVjdHMvU2hlbGJ5dmlsbGVDaHVyY2hvZkdvZC9TaGFyZWREb2N1bWVudHMvMDEtUHJvamVjdCBEZWZpbml0aW9uL015RmlsZS50eHQ="

     

    The error is tha the Root Folder is not found

     

     

  • PowerAutoSwain Profile Picture
    24 on at

    Well, This morning I am really confused and frustrated.  Using "/Shared Documents" in the folder path and the dynamic "File Path" in the File Name parameters, it finally worked. The flow recursively created the OneDrive fo rBusiness new file in the proper folder on SharePoint.

     

    Great, I thought. So I started copying the flow for other Share Point sites we had set up. But when I tested one of those new flows, I got the same problem: the file created at the "Shared Documents" level, but in a new file called "_drives_" and a string of characters.

     

    Crap, I thought. So, I went back to my original flow that had just worked property before and ran a manual test on it. Now it doesn't work properly, but creates the "_drive_" file at the "Shared Documents" folder level. 

     

    Since nothing changed in that flow, can anyone explain why it would work property one minute then not work properly a few minutes later? Since nothing changed on my end, I have to assume that this flow process has a flaw.

     

    I have spent so much time trying to get this to work that I could just as well manually upload the folders each day. I am giving up on Power Automate.  Perhaps I check back in a few months to see if Microsoft has fixed it. In the meantime, DropBox and Google Docs are alternatives that we will be looking at using.

  • PowerAutoSwain Profile Picture
    24 on at

    No. that doesn't work. Get's an error that say the root path can't be found. At least when I use the "/Shared Folder" the flow executes and copies the file to the SharePoint '?Shared Folder" location.

     

    The gofy thing is that early this morning, it worked fine. But when testing it a few minutes later, it started copying the file with a name that began witn "_drive_" and some characters. So, my question is why was it working properly then just decided to stop without any changes being made on my end?

    This setup errorsPowerAutomateError.jpg

     

     

     

    This one works, sometimes but when it doesn't work it adds the file at the "\Shared Documents" folder with the file name that begins with "_drive_".

    PowerAutomateSuccessr.jpg

     

     

     

     

    This "works" but puts the file at the "\Shared Documents" folder with the correct file name.PowerAutomateFileName.jpg

    I think the problem is that the OneDrive for Business Trigger gets a file path that is not always correctly intrepreted by the SharePoint Action. I tried creating a OneDrive for Business path that mirrored the SharePoint path below the site, but that did not work either. 

  • Verified answer
    v-LilyW-msft Profile Picture
    on at

    Hi @PowerAutoSwain 

    Thank you for your posting.

    According to your description, you want to create a file in OneDrive and it can created in SharePoint folder at the same time, if it is created in a subfolder, it can also be created in the SharePoint subfolder accordingly.

    I created a Flow and can achieve it, you can refer to the steps as below:

    vLilyWmsft_0-1624339789137.png

    split(last(split(outputs('Get_file_metadata')?['body/Path'],'Shelbyville Church of God/')),'/')

    vLilyWmsft_1-1624339789140.png

    length(outputs('Compose_3'))

    vLilyWmsft_2-1624339789142.png

    join(take(outputs('Compose_3'),add(outputs('Compose'),-1)),'/')

    vLilyWmsft_3-1624339789144.png

    vLilyWmsft_4-1624339789146.png

    When new file is created in Shelbyville Church of God, the file will be created to ‘Shared Documents

    vLilyWmsft_5-1624339789152.png

    vLilyWmsft_6-1624339789155.png

     

    When a new file is created in ’Shelbyville Church of God/Finance’,the file will be created to ‘Shared Dpcuments/Finance’

    vLilyWmsft_7-1624339789158.png

    vLilyWmsft_8-1624339789160.png

    Hope the content above may help you.
    Best regards,

    If my solution helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • PowerAutoSwain Profile Picture
    24 on at

    This solution does not work for me. I have recreated it several time with the same result. I get this error:

     

    Cannot create folder "sites/ShelbyvilleChurchofGod/Shared Documents/drives/b!JbBJewNaLU61BPdPOMyZnPWtQJpxlZpAkdcZqjunFksFnABH0ysCRJfP7Xv8o2P4/root:".
    clientRequestId: 0f0b1cd1-e269-467b-a75c-9b5ddd147c2a
    serviceRequestId: 0f0b1cd1-e269-467b-a75c-9b5ddd147c2a

  • PowerAutoSwain Profile Picture
    24 on at

    I am using One Drive for Business, not personal One Drive. Could that be the problem? Is your Flow using One Drive or One Drive for Business?

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