cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mboonie
Level 8

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 8

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

View solution in original post

5 REPLIES 5
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 8

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 8

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

View solution in original post

venseben
Level: Powered On

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

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

venseben
Level: Powered On

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

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Users Online
Currently online: 176 members 5,902 guests
Please welcome our newest community members: