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 / Trying to use REST API...
Power Automate
Answered

Trying to use REST API to Check In and Check Out a document in a library

(0) ShareShare
ReportReport
Posted on by 164

OK, so I'm back with another question about something for which there is no Flow connector.

I simply want to update the properties of a document that has been created in a library, and which is Checked In. I understand I will need to create an action with "Send HTTP Request to SharePoint", but the doucmentation on those two particular REST calls leaves me confused.

This page documents it thus:

   url: http://site url/_api/web/GetFileByServerRelativeUrl('/Folder Name/file name')/CheckOut(),
   method: POST
   headers:
      Authorization: "Bearer " + accessToken
      X-RequestDigest: form digest value

I am having difficulty divining what information or arguments the headers take. Could "Authorization" just be the Created By value, since they already clearly have permissions? And I have virtually no non-jquery idea of what to enter for the "X-RequestDigest" value.

Sorry for the rookie question, but there is literally nothing online that I can find about Flow and Check-In that clears any of this up for me.

Thanks in advance!

-Boonie

Categories:
I have the same question (0)
  • v-bacao-msft Profile Picture
    on at

    Hi @mboonie,

     

    You could use the examples provided in this link to implement check in or check out file operations.

    As for what you mean by "Authorization" or "X-RequestDigest", you don't have to configure it.

     

    Best Regards,

    Barry

  • mboonie Profile Picture
    164 on at

    Thank, but that's the article I've been using, so I'm still stumped/stopped. The Check Out method is described as requiring the following:

    url: http://site url/_api/web/GetFileByServerRelativeUrl('/Folder Name/file name')/CheckOut(),

    method: POST

    headers:

        Authorization: "Bearer " + accessToken

        X-RequestDigest: form digest value

    After you indicated that the headers don't have to be configured, I went ahead and tried it without those parameters, but that didn't help; the flow still fails.

    There are no folders in the library; so, with my Compose Output set as the pathname ('/myLibrary/myFilename.docx'), and without configuring the Headers, the request is configured like this:

    SharePointHTTPRequest.png

     
    After I test it, this is the Output:
    Results.png

    And this is the JSON output from the test run:

    {
        "status": 404,
        "message": "clientRequestId: 0282cc43-b710-45ca-afc1-cbd201c7422c\r\nserviceRequestId:
                86ebac9e-60f2-7000-48ce-75d69496baed",
        "source":"https://myDomain.sharepoint.com/teams/ourSite/url/_api/web/GetFileByServerRelativeUrl
                ('/AUC%20SEC%20Requests/hey%20there.docx')/CheckOut()",
        "errors": []
    }

     

    In the Details pane:

    Error

    Action 'Send an HTTP request to SharePoint' failed
    Error Details
    clientRequestId: 0282cc43-b710-45ca-afc1-cbd201c7422c
    serviceRequestId: 86ebac9e-60f2-7000-48ce-75d69496baed
     

    So... I think either some information is completely missing, or I misunderstand what you mean when you say the headers require no configuration.

     

    Is this another thing for which I need to switch back to SPD?

  • Verified answer
    mboonie Profile Picture
    164 on at

    Nevermind... 

    I finally noticed that the error was actually a typo on my part. (D'oh!) Somehow, when composing the Uri, I must have accidentally left or pasted the text "url/" at the beginning of the string. (I do a lot of my formula-composing in Notepad++)

    I removed that, and suddenly all was right with the world again.

    Final string: _api/web/GetFileByServerRelativeUrl('{everythingAfterTheDomainUpToTheFilename}/ {filenameWithExtension}')/CheckOut()

    (And it's fast, too!)

  • Community Power Platform Member Profile Picture
    on at

    Hi @mboonie I have tried your solution, but cannot get it to work. I get this error:

     

    "message": "Cannot add value because header 'Authorization' does not support multiple values.

     

    My flow is set up this way:

    Flow01.PNG

     

    Flow2.PNG

     

    Flow3.PNG

     I have read this article from MS: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest

    And it looks like I have done the right thing: can you guide me in the right direction, or see what I have done wrong?

     

    /Frank

  • Community Power Platform Member Profile Picture
    on at

    Hi again @mboonie. Forget my recent post. i just removed the two headers and everything worked like a charm. Why MS is writing that these have to been used I do not knos, but all of my tests have been going well since the removal of the headers. 😊

     

    Have a great day

     

    /Frank

  • Avgi_Theodorou Profile Picture
    39 on at

    Hello. i have tried the following on the HTTP Request based on your instructions, but it's not working:

    _api/web/GetFileByServerRelativeUrl('testAvgi/Template.xlsx')/CheckOut() 

     

    i get the error:  serverRelativeUrl Parameter name: Specified value is not supported for the serverRelativeUrl parameter.

     

    also tried it like this: _api/web/GetFileByServerRelativeUrl('/testAvgi/Template.xlsx')/CheckOut() and get the error message Server relative urls must start with SPWeb.ServerRelativeUrl

     

    can you help me please?

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard