web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get drive id for Doc L...
Power Automate
Answered

Get drive id for Doc Library selection

(0) ShareShare
ReportReport
Posted on by 204

Hey all, 

I am using the Excel action 'Create Worksheet' and I would like to make the 'Document Library' property dynamic rather than select it from the dropdown. However it does not accept the Document Library 'Display Name' or Id,  it only seems to accept the 'drive' property.

Does anybody know how to get the 'drive' of a document library? I tried sending an HTTP request to SharePoint but I must have something incorrect.

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

    @TorreyFalconer  are you also providing the dynamic file name, in the excel actions of Power Automate, we cant simply provide the library and filename as their actual names, we need to fetch the drive id and file id and use it in the Create Worksheet action, please see below steps on how to do it:

     

    1. Add 'Send an HTTP request to SharePoint' action to the flow and configure it was follows:

    annajhaveri_0-1615557284416.png

    Uri should be _api/v2.0/drive/root:/<filename>

    here replace <filename> with a variable or the actual file name e.g. book1.xlsx

     

    2. Then add Compose action and configure following expression in this compose action

    outputs('Send_an_HTTP_request_to_SharePoint')?['body']['Id']

    annajhaveri_1-1615557388048.png

     

    3. Now again add Compose action and configure following expression in this compose action

    outputs('Send_an_HTTP_request_to_SharePoint')?['body']['parentReference']['driveId']

    annajhaveri_2-1615557487411.png

     

    4. Then in Create Worksheet action configure it as follows, use compose action output in the Document library and file name parameters, as shown in screenshot below

    annajhaveri_3-1615557637797.png

     

     

  • TorreyFalconer Profile Picture
    204 on at

    Thanks! 

    I think this will work but I am still getting a 400 error at the moment with my HTTP request Uri. 
    It just says that it got an unexpected response from the request. 


    I have my Uri input: 

    _api/v2.0/drive/root:/book1.xlsx

     I tried it various ways using a variable, the actual file name etc. (I even tried using the doc library name instead) but still get the same error.
    Any thoughts?

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @TorreyFalconer  could you please let me know following:

     

    1. Excel file name in which you want to create the worksheet? 

    2. Document library in which file exists

    3. Is file added directly under document library or under a folder, if under folder can you share the folder path

     

    With these answers i can help you to figure out what will the Uri in your case

  • TorreyFalconer Profile Picture
    204 on at

    Hey!

     

    File Name: 2021-03_PersonCount.xlsx

    Document Library: Meeting Attendance 
    Not under a folder, directly in the document library!

     

    Hope that helps!

  • Verified answer
    TorreyFalconer Profile Picture
    204 on at

    UPDATE:
    I was able to accomplish this with a work around. 
    1) In my HTTP request to SharePoint I used the uri: _api/v2.0/drives

         It then listed all the drives and drive id's on that site

    2) Then I used Parse JSON to get the values inside the output Body of the HTTP Request
    3)  Then a Filter Array to find the document library I needed (I filtered by name)
    4) Then finally I used a Compose with the Id from the Filter array. *Note - Many Ids may be listed from the output so if this helps anyone it is: @{items('Apply_to_each')?['id']} 

    And of course I set this as a variable because that was a bit of a ridiculous process to get one id. 
    So, a bit nuts, but it works if you are having the trouble with the _api/v2.0/drive/root:/<FileName> uri as I was.

    I believe this is all much easier to achieve using the Microsoft Graph api if you are registered
    But, I hope this helps anyone with the same issue. 


    Thanks for your guidance and help @annajhaveri!

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @TorreyFalconer  the reason why below Uri input did not work for is because your document library name is Meeting Attendance , the below Uri works for default Documents library of the site. If not using default documents library then the solution that you provided is correct, which worked for your scenario

    _api/v2.0/drive/root:/book1.xlsx

     

  • TorreyFalconer Profile Picture
    204 on at

    I configured it exactly like that and it did not work. Glad I found a work around though! 

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @TorreyFalconer I just meant to explain why it didnt work for your scenario. I hope that makes sense.

  • TorreyFalconer Profile Picture
    204 on at

    @annajhaveri it did! Thank you very much for the help!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @annajhaveri  / @TorreyFalconer 

    I tried both ways:

    klee7777_0-1628859270616.png

    But both HTTP Get actions failed with "Unexpected response from the service
    clientRequestId: 6afea342-387b-4c35-ba2b-28bc1b1837d0
    serviceRequestId: d11be59f-a0f6-c000-47d7-b2029fb9b849"

     

    So, I couldn't even proceed to the next step. How were you able to pass that action?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 875

#2
Valantis Profile Picture

Valantis 817

#3
Haque Profile Picture

Haque 481

Last 30 days Overall leaderboard