In fact, it is not difficult to create a list using web service. You can simply use the lists. addlist method.
However, this method has some limitations and there is no way to create it based on the custom list template.
If you need to automatically create a list based on a list template, I did some research and did not find any way to directly use Web Servic.
In this way, I have two ideas:
1. Use Web service to automate all operations, create a basic list, add content type, and create folders .......
In fact, I used to do this all the time.
2. Use SharePoint RPC.
This is a recent study. If you don't talk nonsense, first go to the code.
String.prototype.format = function(){var agrus = arguments;return this.replace(/\{(\d+)\}/g,function (m,i){return agrus[i];});}function NewList(title, description, templateID, customTemplateName){var rpcString = 'Cmd=NewList&Title={0}&Description={1}&ListTemplate={2}&CustomTemplate={3}';rpcString = rpcString.format(title, description, templateID, customTemplateName);var rpcResult = $.ajax({ url: Web_Server_Relative_Url+'/_vti_bin/owssvr.dll', type: 'POST', beforeSend: function(xhr) { xhr.setRequestHeader('X-Vermeer-Content-Type', 'application/x-www-form-urlencoded'); }, data: rpcString, async: true, contentType: 'application/x-www-form-urlencoded' });rpcResult.success(function(data, textStatus, jqXHR){ }).error(function(jqXHR, textStatus){ });return rpcResult; }NewList('Test001', '', '100', 'C1.stp');
For details about how to use SharePoint RPC and create a list, refer to the following article:
- SharePoint RPC-Part 2
- Newlist Method
Slightly explain the code. The newlist method contains four parameters: the title of the new list, the description of the new list, and an ID (I tested it, there is no limit, does not need to be the ID of the Basic Template corresponding to the custom template), custom list template file name.
If you read my code, you will find that there is an additional parameter customtemplate, which makes everything possible.
The origin of this parameter. If anyone is interested, leave a message and I will write it later.