0

I want to share below solution for CheckOut , Upload File and CheckIn on Sharepoint using cURL

#Excel CheckOut

curl -k --data '' --request POST -H "oauth2TokenHeader" "https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder/FileName.xlsx')/CheckOut()"

#Upload File

curl -k --data '' --request PUT -H "oauth2TokenHeader" "https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder/FileName.xlsx')/$value" --upload-file C:\Filename.xlsx

#Excel CheckIn

curl -k --data '' --request POST -H "oauth2TokenHeader" "https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder/FileName.xlsx')/CheckIn(comment='comment',checkintype=1)"

--data '' = for Content-Length 0 -k=skip certificate validation -H=a command line option for the curl command that takes a single parameter of an extra header to include in the request

checkintype=1 for Major Version Update checkintype=0 for Minor Version Update

oauth2TokenHeader if using OAUTH2 then use the tokenheader otherwise use username/password instead

Use below link for more guide

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest

Solution works great I hope it help others.

  • Thank you for sharing! Could you please split this knowledge article in a question ([ask]) and an answer ([answer]). Finally you can accept your own answer. It won't take much time. Otherwise it can happen that some moderator will delete this post because it doesn't comply with the Stackoverflow guideline that questions have to be questions and answers have to be answers. – Markus May 12 '23 at 22:49

0 Answers0