MS graph API sharepoint site. Create a folder in root

依然范特西╮ 提交于 2019-12-02 08:10:59

问题


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).

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

GET /v1.0/sites/SITEID/drives

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?

I try to guess something like

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

But this doesn't work

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"
  }
}

no success


回答1:


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

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

Endpoint

GET /v1.0/sites/SITEID/drives

will return a list of lists with template: document library.

Endpoint

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?



来源:https://stackoverflow.com/questions/44900200/ms-graph-api-sharepoint-site-create-a-folder-in-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!