我已经在SharePoint StackExchange上回答了类似的问题。
总而言之,似乎无法使用 SharePoint 2013 REST API 创建文档集,因为SP.DocumentSet.DocumentSet.create
无法通过 REST 访问函数。但是您可以使用 SharePoint 2010 REST API 来实现该目的。
以下示例演示如何使用 SharePoint 2010 REST 接口创建文档集:
function getListUrl(webUrl,listName)
{
return $.ajax({
url: webUrl + "/_api/lists/getbytitle('" + listName + "')/rootFolder?$select=ServerRelativeUrl",
type: "GET",
contentType: "application/json;odata=verbose",
headers: {
"Accept": "application/json;odata=verbose"
}
});
}
function createFolder(webUrl,listName,folderUrl,folderContentTypeId)
{
return $.ajax({
url: webUrl + "/_vti_bin/listdata.svc/" + listName,
type: "POST",
contentType: "application/json;odata=verbose",
headers: {
"Accept": "application/json;odata=verbose",
"Slug": folderUrl + "|" + folderContentTypeId
}
});
}
function createDocumentSet(webUrl,listName,docSetName)
{
return getListUrl(webUrl,listName)
.then(function(data){
var folderUrl = data.d.ServerRelativeUrl + '/' + docSetName;
return createFolder(webUrl,listName,folderUrl,'0x0120D520');
});
}
用法
Orders
创建在文档库中命名的文档集:
createDocumentSet(webUrl,'Documents','Orders')
.done(function(data)
{
console.log('Document Set ' + data.d.Name + ' has been created succesfully');
})
.fail(
function(error){
console.log(JSON.stringify(error));
});