Can CheckInFile update a docuemnt

Apr 22, 2012 at 5:12 AM

I don't see the file content stream as one of the in-parameters for this service method. So I am wondering if CheckInFile can be used to update a document in a document library. Any insight is appreciated.

Apr 22, 2012 at 7:37 PM

I think you need to use to update a document and I don't think it's mapped into SPServices

This is what I used before to do this. Note that the stream needs to be Base64 encoded


soapEnv =
        "<soap:Envelope xmlns:soap='' xmlns:xsi='' xmlns:xsd=''><soap:Body><CopyIntoItems xmlns=''><SourceUrl>" + filename + "</SourceUrl><DestinationUrls><string>" + pageURL + "</string></DestinationUrls><Fields>" + fields + "</Fields><Stream>" + stream + "</Stream></CopyIntoItems></soap:Body></soap:Envelope>";
        url: wsURL,
        beforeSend: function(xhr) {
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: "text/xml; charset=\"utf-8\""

Apr 22, 2012 at 11:20 PM

Actually, I have all three available operations for the Copy Web Service wrapped with SPServices. It looks like I missed adding the other two into the docs, which I'll do right now.


Apr 22, 2012 at 11:46 PM

Thanks Marc. I was wondering about that. But by looking at the parameters for CopyIntoItems method, doesn't it copy from an existing SharePoint document library to another? I am puzzled about the first sourceUrl parameter, which I don't have because I am not really interested in copy. I am updating a document.

One more question about CheckInFile. If it does not really update a document, what the real purpose of this method? You do a upload and then use this method to check in the file?

Regarding Base64 encoding: is there an official javascript library class for it? Found one from the net ( written in 2005. But not sure if it still works after 7 years. 

Apr 23, 2012 at 12:15 AM

CheckInFile simply checks in a file. I didn't write 'em, I just expose 'em.

To be honest, I haven't done any document uploads with the Web Services, as I haven't run into a need for it.


Apr 23, 2012 at 12:32 AM
Edited Apr 23, 2012 at 12:33 AM

Can't say anything about that Base64 script, but I've used this one and it works

if I remember correctly the SourceUrl is not required if you have a Stream string.

If a document library or list requires checkout, you need to checkout the item before you can update it using the CheckOutFile method, then change the file using CopyIntoItems, then check it in again to make it visisble to users. The CopyIntoItems can be used to automatically create or update files, I've used it mainly to generate html or logfiles and i think it also can be used to copy files between farms, while the CopyIntoItemsLocal only can be used to make a copy of an existing file within the same farm. 


Apr 23, 2012 at 12:39 AM

I understand that CheckInFile is defined by MS. I just could not think a situation that one needs to use it.  

As for Copy web services: There is a comment in this link provided by Fredrik (thank you!) that says that the sourceUrl in CopyIntoItems method can be anything if data stream is provided in the parameter. So I am going to try it out and let you know how it works.

In the last 7 years, I have done a lot of solutions (code) using object model on server side. So there are a lot more freedom to find cost effective solutions. But lately I have a few projects that do not allow server side code when sites are centrally hosted. Thanks Marc for your work in SPServices() so that I don't need to dig down to lower level. The plus side of this constraint is that there are client side solutions that I would never think of if I just stay on the server side.

By the way, Marc, I enjoy your arguments with Mark regarding Web Services and CSOM.

Apr 23, 2012 at 12:51 AM

You're very welcome. SPServices has been a lot of fun for me as well as an excellent learning experience.

Mark and I love debating this stuff. We usually call each other names in private, but we thought it might be useful to put the debate out there for comments this time.


Apr 23, 2012 at 1:07 AM

Thanks fereko. I also found that Base64 code shortly after my post earlier and it works as you said.

I am in the exact situation as your example: store dynamically generated html code somewhere so that page can be loaded it directly without real time query or xslt to improve performance.  Beside using document library, I also found that using attachments (deleteAttachment and addAttachment method) to a custom list will also work in this situation, which I think is bit simpler. But I will try Copy web service out just for the sake of understanding it.

Apr 23, 2012 at 2:12 AM
Been watching this thread very closely. The ability to save dynamically generated content (in the browser via JavaScript) and saving that to a file on sharepoint is of interest. Thank you for the postings.

I have not run across the need to update a file's content (yet). But have solved the need to upload a file without having the user navigate away from the current page.

I developed a JavaScript plugin that allows a user to upload a file via 'Ajax'. I placed quotes around Ajax because it realy is not Ajax, but rather done via a manipulated sharepoint upload.aspx file displayed in an iFrame.

I have watched your contributions on this forum and they have been very insightful. Thank you and keep it up.


Sent from mobile device.

Apr 23, 2012 at 12:32 PM

Now for this I have to add my 1 cents worth due to inflation! I have used the copy service to create Excel files in a document library. I never tried in any other browser but IE, but I did use XML and XSL to create reports in Excel and "save" them to the library and then show them Excel. I used the Base64 javascript code and I basically build my own "Export to Spreadsheet" option to support fields or data that would not otherwise export.

Apr 23, 2012 at 5:17 PM


I would love to see the code you used to create the excel file via javascript. Any chance you can post?


Apr 23, 2012 at 5:29 PM

I had an older blog post on this that may be helpful located here with some updated code here but I have been meaning to make an upadted post on my newer blog site.

Apr 23, 2012 at 5:37 PM
Great! Thanks.

Paul T

Apr 29, 2012 at 4:05 AM
Edited Apr 30, 2012 at 12:51 AM

Just to report back that Copy in SPServices() does move documents from one library to another. It also stores known base64 string to a document library as long as one gives destination URLs and a valid source URL that is not used. But I found another interesting thing while moving html files: SharePoint adds some <mso> tags to the end of the copied file. Still trying to figure out how to get rid of those annoying extra tags.

Apr 30, 2012 at 7:33 PM

Also, I have been successful using the destination URL as the source URL as well. This has made it easier for the code to work and sometimes seems to set the items parent link to itself which works fine for what I did.