On Tue, Jun 23, 2009 at 8:42 AM, Bierman, Stijn <stijn.bier...@wur.nl>wrote:
> Dear List, > > Sharepoint sites are used more and more often by researchers as a > platform to share all the information in a joint research project. > Typically, they can be accessed only by a Hypertext Transfer Protocol > Secure (HTTPS) URL. > We are investigating whether it is possible to read and write data to > Microsoft Sharepoint sites using R. > > We have managed to open a read-only connection to read data from > sharepoint sites using the 'url' function (connections{base}), for > example: > > conn <- url(description="https://path_to_sharepointsite/data.csv", open > ="r); > > dat <- read.table(file=conn, sep=","); > > However, it appears that URLs can only be opened for reading; from the > connections{base} help file: > "Not all modes are applicable to all connections: for example URLs can > only be opened for reading." > > Does anyone know how to open a write connection to a microsoft > sharepoint site, or how to open a URL connection for writing? > > You can't just write to a URL like you can to a file or other stream-type thing. What you are actually doing when you upload something to a web site is construct an HTTP request with the file as a 'payload', and then send this all to the web site. HTTP requests come in a small number of flavours: the GET request is what is usually used to query information from a web server, and the POST request is what is usually used to upload files or send the contents of online forms and so on. Note however that GET requests can be (mis-)used to 'write' data to a web server. That's not their purpose - GET requests should not change the state on the server, but this just gets us into the whole debate about RESTful web services... Once you've reverse-engineered the Sharepoint protocol (which may be illegal in your jurisdiction - please read the 200 page Microsoft License Agreement, or read it again, because surely you read it before you started using Sharepoint), you'll see that it probably (unless MS have ignored web standards, but is that something they'd do?) uses POST requests to upload files. You'll also have to figure out how it authenticates users. Probably uses cookies. Now things get a bit tricky. The best place to look for more info now is the RCurl package - this lets you send GET and POST requests to HTTP servers. See help(postForm) in RCurl for more. Also, get a book on web services and protocols to learn more about HTTP - there's lots of pitfalls (encodings etc). However you may find someone has done most of the reverse-engineering for you, since there could well be RESTful API wrappers for SharePoint. A bit of googling finds this: http://www.businesswire.com/portal/site/google/?ndmViewId=news_view&newsId=20090209005537&newsLang=en so you could either throw more money at the problem that way. Also this: http://www.codeplex.com/REST4SharePoint which is a project that could do with some help, so maybe you could throw some time at that. The big problem here is that MS could change their protocol at any time, and you'd be stuffed. Proper Solution: Use a collaboration platform with an open, published, documented API. Drop SharePoint asap before you lock your data into a proprietary system with increasing license fees. Encourage everyone to do likewise (which is what I'm doing here). Barry [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.