Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Filename in HTTP request to SharePoint and Rest API

(1) ShareShare
ReportReport
Posted on by 39
I want to check out a file in a SharePoint library using Power Automate (HTTP request to SharePoint and Rest API)
 
It works when I hardcode the filename. Ex. _api/web/GetFileByServerRelativeUrl('/sites/TheSite/TheLibrary/filename.docx')/CheckOut() 
 
However when I add the filename dynamically in the following way (and others ways that I also tried), the filename is not displayed. The filename exists because I'm able to write it to a column of the library. Your help would be appreciated :)

  • Suggested answer
    SaiRT14 Profile Picture
    1,988 Super User 2025 Season 1 on at
    Filename in HTTP request to SharePoint and Rest API
    Follow the below steps and let me know: 
    • Trigger the flow (e.g., when a file is created or modified).
    • Add an action to get the file properties if needed.
    Use the HTTP Request to SharePoint action in Power Automate to send the request.
    _api/web/GetFileByServerRelativeUrl('@{encodeUriComponent(triggerOutputs()?['body/{Path}'])}')/CheckOut()
     
    Headers:  Ensure that the headers are set properly for the API request:
    • Accept: application/json;odata=verbose
    • Content-Type: application/json;odata=verbose
    _api/web/GetFileByServerRelativeUrl('@{triggerOutputs()?['body/{Path}']}')/CheckOut()
     
     
     
  • Verified answer
    abm abm Profile Picture
    32,488 Most Valuable Professional on at
    Filename in HTTP request to SharePoint and Rest API
    Hi
     
     
    So I have tested this and you need to encode the uri.
     
    Here are the steps:
     
  • KTNN0 Profile Picture
    39 on at
    Filename in HTTP request to SharePoint and Rest API
    And if I hard code the name of the file, it works. The file is checked out.
     
     
  • KTNN0 Profile Picture
    39 on at
    Filename in HTTP request to SharePoint and Rest API
    Thank you for your help. I simplied the flow to concentrate on the issue. The flow is triggered manually on a SharePoint file. Then it adds the filename to the Title properties. I added the compose also just to show that the filename with the extension exists, as suggested. And finally at the HTTP request, where the filename is not displayed.
    Compose:
    HTTP Request:
  • Verified answer
    Michael E. Gernaey Profile Picture
    43,417 Super User 2025 Season 1 on at
    Filename in HTTP request to SharePoint and Rest API
    Hi
     
    Yeah I would validate that the filename has the extension. As I cannot see your flow etc, not sure that it does, or how you are gathering the information pre-post action, if you can share your flow too.

    You can also, go into your Flow History, pick one of the runs that you rested, where the variable was being used. You can go to the action itself, and see what was the URL that it generated fully.

    Copy it out. Make sure the extension is there. Make sure there are no spaces unintentionally, as you might have to add a trim() etc.
  • Verified answer
    abm abm Profile Picture
    32,488 Most Valuable Professional on at
    Filename in HTTP request to SharePoint and Rest API
    Hi
     
    Couple of ways you could debug this.
     
    Add a compose above the http step. Map the fileName under the compose. Run the flow and check the run history. Expand the compose and see whether the filename appears or not. Next check where the fileName getting from. Expand that step and see why fileName is not appearing. Most likely it must be a folder. In that case you need to check whether its not a folder or not using an IF condition. I can only suggest the IF condition if you could post a screenshot of your flow. That will be helpful to determine what's going.
     
    Thanks

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492