MS 图形 API 共享点站点.在根目录下创建文件夹根目录、文件夹、图形、站点

2023-09-06 17:22:42 作者:后来的我们

我尝试使用 MS 图形 API 来处理共享点站点.一切正常,除了我找不到如何在站点的根目录中创建文件夹(文件夹是文档库).

I try to use the MS graph API to work with sharepoint sites. All works fine, except i can not find how to create a folder in root of a site (folders are documents library).

如果我知道站点 ID (SITEID),我可以将站点根目录中的文件夹列为驱动器

If i know the site id (SITEID) i can list folders in root of the site as drives

GET /v1.0/sites/SITEID/drives

我有每个项目的 ID(它就像一个驱动器 ID).i 可以列出驱动器上的文件夹(它们是站点上顶级文件夹的子文件夹)

I have ID for each item (it is like a drive ID). The i can list folders on drives (which are subfolders of top level folders on a site)

GET /v1.0/sites/SITEID/drives/DRIVEID/root/children

我可以在这个地方创建文件夹和子文件夹

I can create folders in this place and subfolders

POST /v1.0/sites/SITEID/drives/DRIVEID/root/children
{
  "name": "New Folder 2",
  "folder": {}
}

但是如何在网站上创建顶级文件夹?实际上,如何在网站上创建新的驱动器?

But how to create a top level folder on a site? In fact, how to create new drive on a site?

我试着猜测类似的东西

POST /v1.0/sites/SITEID/drives
{
  "name": "New Drive",
  "folder": {}
}

但这不起作用

另外,我尝试创建一个列表 https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/list_create

Also, i tried to create a list https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/list_create

POST /v1.0/sites/SITEID/lists
{
  "name": "Books",
  "columns": [
    {
      "name": "Author",
      "text": { }
    },
    {
      "name": "PageCount",
      "number": { }
    }
  ],
  "list": {
    "template": "documentLibrary"
  }
}

没有成功

推荐答案

我觉得你错了.文件夹不是文档库.

I think you are wrong. Folders are not document libraries.

Drive 是一个文档库.文档库是一个带有template:document library的列表,所以drive也是一个列表.

Drive is a document library. Document library is a list with template: document library, so drive is also a list.

端点

GET /v1.0/sites/SITEID/drives

将返回带有模板的列表列表:文档库.

端点

GET /v1.0/sites/SITEID/lists

将返回所有类型的所有列表.

will return all lists of all types.

要创建新的驱动器(一个文档库),您应该使用文档库作为模板创建一个新列表.然后您将在站点的根目录中拥有一个新驱动器.

To create new drive (a document library) you should create a new list with document library as template. Then you will have a new drive in a root of the site.

您在创建新列表时遇到什么问题?

What problem do you have with creation of a new list?