【问题标题】:How do I upload files to the sharepoint shared documents folder (https://mycompany.sharepoint.com/Shared%20Documents) using Microsoft Graph Client如何使用 Microsoft Graph 客户端将文件上传到 sharepoint 共享文档文件夹 (https://mycompany.sharepoint.com/Shared%20Documents)
【发布时间】:2018-08-07 21:49:06
【问题描述】:

如何使用 Microsoft Graph 客户端将文件上传到 sharepoint 共享文档文件夹。我在 API 文档中没有看到任何相同的示例。是否可以通过 Graph 客户端 API 实现相同的功能

【问题讨论】:

    标签: microsoft-graph-api


    【解决方案1】:

    以下作品

            Stream filecontents = new MemoryStream(filedata);
            await client.Drive.Root.ItemWithPath(NameOfFile).Content.Request().PutAsync<DriveItem>(filecontents);
    

    【讨论】:

      【解决方案2】:

      如果您不坚持将文件上传到 SharePoint 共享文件夹,您可以使用 OneDrive SDK 来实现您的要求(或 MS Graph OneDrive API)。

      如果你坚持上传文件到SharePoint而不是OneDrive(虽然OneDrive是一个特定的SharePoint站点),你可以看到如下答案:

      我们可以使用以下 API 来操作 Documents 文件夹: 访问给定站点的默认驱动器(文档库)。 /sites/{site-id}/drive

      Enumerate the drives (document libraries) under the site.
      /sites/{site-id}/drives 
      

      您可以尝试以下 API 上传文件:

      PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
      

      更多信息:

      https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/driveitem_put_content

      https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/sharepoint

      如果上述解决方案对您不起作用,那么结果将是我们现在无法通过 MS Graph Client 直接将文件上传到 SharePoint Shared Documents 文件夹。目前,Microsoft 仅支持以下有限的常用功能:List/Site/ListItem。

      如果 API 对您不起作用,您可以向产品组提交功能请求:https://officespdev.uservoice.com/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-14
        • 1970-01-01
        • 2020-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-25
        相关资源
        最近更新 更多