I'm working on a tool that will help my team in creating large numbers of libraries on a given site. Unfortunately, I can use only SOAP/REST interface to perform needed actions. I developed a simple form that contains of a textbox to provide SP site's URL and a DataGridView with columns: Name, Descritpion, FeatureID and Template to enter the library data.

So here is the code:

private void addLibraryList_Click(object sender, EventArgs e)
        ListsProd.Lists listReference = new ListsProd.Lists();
        string URL = siteUrl.Text;
        if (URL[URL.Length - 1].ToString() != "/")
            URL += "/";
        listReference.Url = URL + "_vti_bin/lists.asmx";
        listReference.Credentials = CredentialCache.DefaultNetworkCredentials;
        foreach (DataGridViewRow row in libraryList.Rows)
            if (row.Cells["name"].Value != null && row.Cells["description"].Value != null && row.Cells["featureId"].Value != null && row.Cells["template"].Value != null) 
                string listName = row.Cells["name"].Value.ToString();
                string description = row.Cells["description"].Value.ToString();
                System.Guid featureId = new Guid(row.Cells["featureId"].Value.ToString());
                int templateId = Int32.Parse(row.Cells["template"].Value.ToString());
                XmlNode xmlResponse = listReference.AddListFromFeature(listName, description, featureId, templateId);
                XmlDocument xmlDoc = new System.Xml.XmlDocument();
                XmlNode ndProperties = xmlDoc.CreateNode(XmlNodeType.Element, "List", "");
                XmlAttribute ndQuickLaunchAttrib = (XmlAttribute)xmlDoc.CreateNode(XmlNodeType.Attribute, "OnQuickLaunch", "");
                ndQuickLaunchAttrib.Value = "True";
                XmlNode ndReturn = listReference.UpdateList(row.Cells["name"].Value.ToString(), ndProperties, null, null, null, null);
                row.Cells["status"].Value = "DONE";
        MessageBox.Show("All done!");


I can successfully add libraries using this form but in some cases I also need to set the MajorVersionLimit to other value than in the list template.

I tried to pass that attribute directly to UpdateList method but it doesn't work. MajorVersionLimit isn't listed on the method's properties list: https://msdn.microsoft.com/en-us/library/lists.lists.updatelist(v=office.12).aspx but the funny thing is, that "OnQuickLaunch" attribute isn't listed there either and it works perfectly.

So - is there any way to update the MajorVersionLimit attribute using SOAP or REST interface?


The following JavaScript example shows how to update SP.List.MajorVersionLimit property via REST Interface:

var properties = {
  MajorVersionLimit: 50
    console.log('List has been updated');
    console.log('An error occured while updating a list');


function executeJson(url,method,headers,payload) 
    method = method || 'GET';
    headers = headers || {};
    headers["Accept"] = "application/json;odata=verbose";
    if(method == "POST") {
        headers["X-RequestDigest"] = $("#__REQUESTDIGEST").val();
    var ajaxOptions = 
       url: url,   
       type: method,  
       contentType: "application/json;odata=verbose",
       headers: headers
    if (typeof payload != 'undefined') {
      ajaxOptions.data = JSON.stringify(payload);
    return $.ajax(ajaxOptions);

function updateList(webUrl,listTitle,properties){
    var url = webUrl + "/_api/web/lists/getByTitle('" + listTitle + "')";
    var payload = properties;
    payload["__metadata"] = { "type": "SP.List" };
    var headers = {
        "X-HTTP-Method": "MERGE",
        "If-Match": "*"
    return executeJson(url,'POST',headers,payload);              

Note: have been verified against SharePoint Online

  • I missed one important information - I connect to SharePoint 2010. So unfortunately there is no "_api/web/lists" interface, just the old "_vti_bin/listdata.svc" which returns only list's items and no properties to modify... That's why I cannot use MERGE or PUT methods. – Alek Wnuk Oct 26 '15 at 21:21

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.