I've been tasked with connecting with a Sharepoint document library from our website which is built with Django. I need to list all the documents in the library on a page and then allow them to be downloaded. I've looked around at the API docs and I'm very overwhelmed. I'm not sure where to start. We're running Sharepoint 2010. Anyone know where the best place to start on this would be? Any tutorials out there on doing something like this?

  • <strike>You tagged rest-api in your response. Are you calling the SharePoint object model from a client solution or from a server solution?</strike> Sorry, I missed a few words. You want to call SharePoint from the JavaScript client object model since you already have a website built with Django. – Jeff Freeman May 8 '14 at 21:34

Start here. The JavaScript function retrieveListItems() is what's important. Let me copy it here for posterity:

function retrieveListItems() {

    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Announcements');

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' + 
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
    this.collListItem = oList.getItems(camlQuery);


    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));        

In that code, replace Announcements with the title of your list.

The CAML query is there to basically filter the number of items in your list (which could be in the millions!), so let me break it down for you:

                <FieldRef Name='ID'/> 
                <Value Type=\'Number\'>1</Value>

This CAML query returns the first 10 items whose List Item ID (relative to the list) is greater than 1. More about CAML is a little out of scope for this box, but here's some links to help you get started:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.