How to auto upload and check in the files to sharepoint using curl? How to auto upload and check in the files to sharepoint using curl? curl curl

How to auto upload and check in the files to sharepoint using curl?


I don't have curl available to test right now but you might be able to fashion something out of the following information.

Check in and check out is handled by /_layouts/CheckIn.aspx

The page has the following querystring variables:

List - A GUID that identifies the current list.

FileName - The name of the file with extension.

Source - The full url to the allitems.aspx page in the library.

I was able to get the CheckIn.aspx page to load correctly just using the FileName and Source parameters and omitting the List parameter. This is good because you don't have to figure out a way to look up the List GUID.

The CheckIn.aspx page postbacks to itself with the following form parameters that control checkin:

PostBack - boolean set to true.

CheckInAction - string set to ActionCheckin

KeepCheckout - set to 1 to keep checkout and 0 to keep checked in

CheckinDescription - string of text

Call this in curl like so

curl --data "PostBack=true&CheckinAction=ActionCheckin&KeepCheckout=0&CheckinDescription=SomeTextForCheckIn" http://{Your Server And Site}/_layouts/checkin.aspx?Source={Full Url To Library}/Forms/AllItems.aspx&FileName={Doc And Ext}

As I said I don't have curl to test but I got this to work using the Composer tab in Fiddler 2

I'm trying this with curl now and there is an issue getting it to work. Fiddler was executing the request as a POST. If you try to do this as a GET request you will get a 500 error saying that the AllowUnsafeUpdates property of the SPWeb will not allow this request over GET. Sending the request as a POST should correct this.

Edit I am currently going through the checkin.aspx source in the DotPeek decompiler and seeing some additional options for the ActionCheckin parameter that may be relevant such as ActionCheckinPublish and ActionCheckinFromClientPublish. I will update this with any additional findings. The page is located at Microsoft.SharePoint.ApplicationPages.Checkin for anyone else interested.


The above answer by Junx is correct. However, Filename variable is not only the document filename and the extension, but should also include the library name. I was able to get this to work using the following.

Example: http://domain/_layouts/Checkin.aspx?Filename=Shared Documents/filename.txt


My question about Performing multiple requests using cURL has a pretty comprehensive example using bash and cURL, although it suffers from having to reenter the password for each request.