Microsoft Graph API创建带有自定义元数据列的文件夹

时间:2020-10-15 10:30:35

标签: microsoft-graph-api

作为使用Graph API在Microsoft团队中创建团队的一部分,我试图在Microsoft Graph中创建带有自定义列的文件夹-只是一个简单的是/否。

这是我到目前为止所拥有的:

            var newFolder = new DriveItem();
            newFolder.Name = folderName;
            newFolder.Folder = new Folder();

            newFolder.AdditionalData = new Dictionary<string, object>();
            newFolder.AdditionalData.Add("@microsoft.graph.conflictBehavior", "rename");

            var newSubFolder = _graphClient.Groups[team.RemoteId].Drive.Items[parentFolder.RemoteId].Children
                .Request().AddAsync(newFolder).Result;

但是,我需要在创建时(或之后,如果需要在更新调用中)向该文件夹添加一个自定义列。我希望可以通过Graph API轻松完成此操作,但似乎找不到任何方法。有人知道吗? (顺便说一句,我不知道如何访问底层的SharePoint API,所以即使我知道如何使用SharePoint进行操作,目前也无济于事。)

1 个答案:

答案 0 :(得分:0)

尝试以下步骤:

(1)创建文件夹:

POST /drives/{drive-id}/items/root/children 
{ "name": "{test}", "folder": { }, "@microsoft.graph.conflictBehavior": "fail" } 

(2)获取创建的文件夹的项目ID,并更新文件夹的内容类型,元数据:

PATCH /sites/{site-id}/lists/{library-name}/items/{item-id} { "contentType": { "id": "{content-type-id}" }, "fields": { "fieldname1": "{value}", "fieldname": "{value}" } }