【发布时间】:2018-03-01 12:50:27
【问题描述】:
我正在努力通过 SharePoint Online 中的 REST API 创建文档集。我发现这样做的唯一解决方案是通过以下方式使用旧的 SharePoint 2010 REST 接口:
$http({
method: "POST",
url: url + "/_vti_bin/listdata.svc/" + listTitle,
data: JSON.stringify(docSetOptions),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $('#__REQUESTDIGEST').val(),
"Slug": _spPageContextInfo.siteServerRelativeUrl + "/" + url + docSetOptions.Path + "/" + docSetOptions.Title + "|" + docSetOptions.ContentTypeId,
}
}).success(function (data, status, headers, config) {
logtoconsole("document set created");
}).error(function (data, status, headers, config) {
logtoconsole("document set error");
});
docSetOptions 是那些:
var folder = new
{
Title = "foo",
Path = "foo",
ContentTypeId = "0x010050D9126DC6276846BF6D869EF2090EAD",
ContentType = "SP.Data.Shared_x0020_DocumentsItem",
};
id 是我的自定义内容类型的 id,源自文档集。
来源:http://www.itidea.nl/index.php/create-a-document-set-using-jsom-and-rest/
这对我有用,但会创建一个常规文件夹。没有文档集。有人知道这在 SharePoint Online 中是否仍然有效吗? 我发现的唯一条目是关于 SharePoint 2013。
更新:我在 Premise Server 上针对我的 SharePoint 2013 运行了相同的脚本,它运行良好。文档集已创建。微软几个月前改变了这一点。以前是可以的!
【问题讨论】:
-
您使用的内容类型 ID 不正确。对于文档集,它应该是
0x0120D520 -
不,我的 id 就是由此派生的。就像我已经写过的那样:“id 是我的自定义内容类型的 id,源自文档集。”如果我使用“0x0120D520”,我也会遇到同样的问题。文件夹已创建...
-
即使您从数据中删除 ContentType 键也可以使用
标签: rest sharepoint sharepoint-2010 office365