cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mboonie
Level: Powered On

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

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

1 ACCEPTED SOLUTION

Accepted Solutions
mboonie
Level: Powered On

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

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!)

3 REPLIES 3
Community Support Team
Community Support Team

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

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

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mboonie
Level: Powered On

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

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?

mboonie
Level: Powered On

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

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!)

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 477 members 4,664 guests
Please welcome our newest community members: