是否可以使用图形 API 创建项目文档集? [英] Is it possible to create a project documentset using graph API?

查看:24
本文介绍了是否可以使用图形 API 创建项目文档集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我还没有找到有关如何使用 Graph API 在我的 Sharepoint 环境中创建项目文档集的任何信息.我已经尝试过 Sharepoint 的 'Create item' 和 OneDrive 的 '创建文件夹'.Sharepoint API 说:

So far I haven't been able to find any information on how to create project documentsets on my Sharepoint environment using the Graph API. I've tried both Sharepoint's 'Create item' and OneDrive's 'Create Folder'. The Sharepoint API says:

"Files and folders should only be added to a DocumentLibrary via the OneDrive API"

OneDrive API 说:

The OneDrive API says:

"Either 'folder' or 'file' must be provided, but not both."

从回复中可以看出,它似乎仅限于创建文件夹或文件的选项.这个对吗?有没有办法使用不同的 API 调用将文件夹更改为文档集?

As you can tell from the responses, it seems limited to only having the options to create either a folder or a file. Is this correct? Is there any way to mutate a folder to a document set using a different API call?

我尝试将内容类型 ID 添加到不同的请求正文中,但在每种情况下都没有提供进一步的解决方案.

I have tried to add the content type ID to the different request bodies, in every case providing no further solution.

希望这里有人知道可能的解决方案并可以帮助我.谢谢!

Hope someone here knows a possible solution and can help me. Thanks!

推荐答案

我今天处理了同样的问题.在一些业务逻辑之后,我需要在文档库的根级别创建一个文档集.

I've dealt with the same issue today. I needed to create a Document Set in the root level of a Document Library after some business logic.

这是我这样做的方法:

1- 获取文档库的 Drive Id:

GET https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}?$expand=drive

2- 创建文件夹:

POST https://graph.microsoft.com/v1.0/drives/${library.drive.id}/root/children

记得将body设置为:

Remember to set the body as:

{
    "name": ${nameOfTheFolder},
    "folder": {},
}

3- 获取文件夹的 SharePoint 项目 ID:

GET https://graph.microsoft.com/v1.0/sites/${siteId}/drives/${library.drive.id}/items/${folder.id}?expand=sharepointids 

4- 更新文档库中的项目,使其更新为所需的文档集:

PATCH https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/items/${sharepointIds.listItemId}

不要忘记将 body 设置为:

Don't forget to set the body to:

{
  "contentType": {
    "id": "content-type-id-of-the-document-set"
  },
  "fields": {
    //whatever fields you want to set
  }
}

希望对你有帮助

这篇关于是否可以使用图形 API 创建项目文档集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆