cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mboonie
Resolver I
Resolver I

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

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

6 REPLIES 6
v-bacao-msft
Community Support
Community Support

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.

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?

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

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

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
Helper I
Helper I

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?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Kudoed Authors
Users online (1,562)