【问题标题】:Create document set with REST in SharePoint Online在 SharePoint Online 中使用 REST 创建文档集
【发布时间】: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


【解决方案1】:

好的,我找到了解决方案。 一段时间以来,如果使用站点内容类型 ID,则无法通过 REST 创建文档集。 就我而言,我必须使用库中内容类型的 id。 所以我去我的图书馆设置,选择我的内容类型并复制它。这 id 略有不同。在我的例子中是 0x0120D5200085474276CB6D314E9BC0E6F067D47DBE。但在你的情况下,它看起来会有所不同。 如果我使用这个 id,我的文档集就创建成功了! 这花了我几个小时才知道。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-08
    • 2018-12-17
    • 2021-08-22
    • 1970-01-01
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 2019-05-24
    相关资源
    最近更新 更多